[issue14285] Traceback wrong on ImportError while executing a package

Martin Panter report at bugs.python.org
Thu Jul 17 09:25:34 CEST 2014


Martin Panter added the comment:

A file called “package/__main__.py” is executed as a script by “python -m package”. See <https://docs.python.org/dev/library/__main__.html>.

I’ve came across this issue myself. You don’t even need the __main__.py file to be doing anything special, as long as the __init__.py raises an ImportError, I think. On Python 3.4 the report is even more convoluted:

/sbin/python3: Error while finding spec for 'package.__main__' (<class 'ImportError'>: No module named 'missing_module'); 'package' is a package and cannot be directly executed

I dunno what “finding spec” means, and packages _can_ be directly executed if they have a __main__ module, so at least the last bit is definitely wrong.

----------
nosy: +vadmium
versions: +Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14285>
_______________________________________


More information about the Python-bugs-list mailing list