You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use %run -m to run modules within some packages, but it doesn't work quite like python -m: it doesn't support relative imports.
For example, I have the following two files:
./foo/init.py
x = 1
./foo/bar.py
from . import x
print x
With python -m foo.bar or ipython -m foo.bar the output is x. With %run, however:
>>> run -m test.bar
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/IPython/utils/py3compat.py", line 179, in execfile
__builtin__.execfile(filename, *where)
File "/private/tmp/test/bar.py", line 1, in <module>
from . import x
ValueError: Attempted relative import in non-package
The text was updated successfully, but these errors were encountered:
I'm trying to use
%run -m
to run modules within some packages, but it doesn't work quite likepython -m
: it doesn't support relative imports.For example, I have the following two files:
./foo/init.py
./foo/bar.py
With
python -m foo.bar
oripython -m foo.bar
the output isx
. With%run
, however:The text was updated successfully, but these errors were encountered: