I have folder structure as shown in the below. I want to import module1.py
file to my script.py
file.
└── project
├── package1
│ ├── module1.py
│ └── module2.py
└── package2
├── __init__.py
└── script.py
Here is my script.py
file
from package1.module1 import module1
mdl = module1()
print(mdl.get_name())
I have executed the script.py
file as python3 script.py
in the linux terminal. It says no module name module1
Traceback (most recent call last):
File "script.py", line 3, in <module>
from package1.module1 import module1
ModuleNotFoundError: No module named 'package1'
How Can I resolve this issue and maky my script.py
executed.