There is the following file structure.

/home/myusername/python/ │ ├── new_proj │  ├── __init__.py │  └── script.py │ ├── oth_project │  ├── __init__.py │ └── script.py │ └── __init__.py 

If in the script located in the new_proj directory try to import something from oth_project as follows (without adding additional paths to sys.path ):

 from python.oth_project import script 

That, it is expected, an error:

 ImportError: No module named 'python' 

Now, if before importing your module run

 import ipdb 

then the import is done.

Only the following paths are added to sys.path :

 '/usr/local/lib/python3.5/dist-packages/IPython/extensions', '/home/myusername/.ipython' 

So, the question interests, ipython changes the import mechanism not only in its interactive mode? And can you rely on the performance of such imports for the future?

  • And why do not you want to import as from ..python.oth_project import script (two points after from )? - Ilia w495 Nikitin
  • First, it is SystemError: Parent module '' not loaded, cannot perform relative import . Secondly, I wanted to know what exactly changes ipdb imports. - mkkik
  • About the first - if this is python3.5 then, as I understand it, this should not be so. The second is probably the most reliable in the ipdb code ipdb look. - Ilia w495 Nikitin

0