Reputation: 179
I had a python project structured like this:
--prj
----app
------__init__.py
------mod1.py
------run.py
----README.md
and run.py's content is
from app.mod1 import *
when I run in windows it works perfectly fine. In Ubuntu, it reported that "ModuleNotFoundError: No module named 'app'"
the start argument is simple "cd ...prj/app; python3.6 run.py"
I tried to find out the sys.path, by "python3.6 -c 'import sys;print(sys.path)'" the result is
['', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages']
Why would that happen?
Upvotes: 0
Views: 85
Reputation: 1
First thing you I feel is wrong is that every folder and sub folder should have init.py for packages to work in python which isn't present in the app and project folder.
also store the package in the '/usr/lib/python3.6/lib-dynload' and try importing the package.
Upvotes: 0
Reputation: 141
The problem occurs because the name of your python script is the same than the module name. Try to rename app.py, for instance to app_main.py and it should work.
Upvotes: 1