I have this directory structure:
├── package1
│ ├── __init__.py
│ └── package2
│ ├── __init__.py
│ └── module2.py
└── script.py
The script.py file looks like this:
import package1.package2.module2
import package1.package2
if __name__ == '__main__':
package1.package2.module2.run() # This works
package2.module2.run() # This fails
Execution fails with this error, NameError: name 'package2' is not defined.
How can I change the code in such a way that package2.module2
is recognized as an imported module?