How to import python script from submodule?

I have the following python module structure:

/foo.py
/module
/module/__init__.py
/module/submodule/__init__.py
/module/submodule/bar.py

in foo.py I have the following code:

from module.submodule.bar import *

But as a result, I get the following error:

'.../module/bar.py': [Errno 2] No such file or directory

Why is python trying to find the file on /module/bar.py but not the module / submodule / bar, as I said in the import?

+3
source share
1 answer

This was a PyCharm bug. If you move your script from one folder to another, it saves the old path and works with it, even if you changed it in Run config. Therefore, restoring Run config solves the problem.

+1
source

All Articles