0

I read here What is __init__.py for? that init.py is not needed for importing modules from other packages in python versions above 3.3. I have created a dummy program to try out importing. Here is the file structure:

package_1
  |
   --- module1.py

package_2
  |
   --- module2.py

module1.py:

class Class1():
    def __init__(self):
        print("In module 1")

module2.py

from package_1.module1 import Class1

if __name__ == "__main__":
    c1 = Class1()
    print("Working in Class2")

I get the following error when I run module2.py:

ModuleNotFoundError: No module named 'package_1'

Any insight?

1 Answers1

0

The same is working for me , please see the attached screenshot.

enter image description here

Gagan
  • 5,416
  • 13
  • 58
  • 86