0

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.

enter image description here

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.

Mandroid
  • 6,200
  • 12
  • 64
  • 134

1 Answers1

0

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.

hiiwave
  • 40
  • 3