I have following directory structure: ProjectRoot is root project directory. It contains directory 'a' which has mypython.py, which in turn contains a class MyPython. At same level as 'a', there is another directory 'b', which contains file named another.py.
I am trying to import MyPython class in another.py as:
from a.mypython import MyPython
But during execution this gives error as:
ModuleNotFoundError: No module named 'a'
I event tried to put __init__.py' in a as suggested by many, but still no success.
How to get it working? Its Python 3.7.
If you're doing python b/another.py
, this cannot work. Please try python -m b.another
instead (after touch a/__init__.py
).
You can read this question for more information.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.