I am having the error shown in title. The context is this:
- MainDir
- PackageDir
__init__.py
otherpython.py
- ScriptDir
script.py
(which imports Package)
- PackageDir
If I go in a terminal while in MainDir and run python ScriptDir/script.py
I get the error in the title, that is that my package is not found.
If, however, I open a python interpreter from the MainDir, and then import the package, the package is found without issues.
MainDir > python
>>> import Package #No problems
Note that PYTHONPATH
contains the PackageDir. When checking the sys.path
, the output contains the absolute path to the PackageDir
, that is
sys.path = ['/home/user/MainDir/PackageDir','PathToAnaconda',...]
is part of the outputed list.
I am very confused what is going on here, could anyone help me? Thank you