Reputation: 2095
I have a development server running in virtualenv
(Python 3.6), into which I want to install a local python project. If I run pip install -e /path/to/myproject
while virtualenv
is active, then inside that environment I can import myproject
. I can also do from myproject import submodule
. But if I do from myproject import othermodule
, I get ModuleNotFoundError: No module named 'submodule'.
(othermodule
imports submodule
). This does not happen if I import myproject
from myproject
's root.
The directory structure is:
/path/to/myproject
setup.py
myproject/
__init__.py
submodule.py
othermodule.py
...
setup.py
looks like:
setup(
name='myproject'
packages=['myproject']
)
What's going on? Why aren't those libraries found?
Upvotes: 0
Views: 731
Reputation: 2095
The issue was that Python 3 relative imports must be explicit.
In othermodule
, instead of
import submodule
I need to write:
import myproject.submodule
or
import .submodule
Upvotes: 1