'Python Package Import Design

I have a python package that works perfectly if it's installed with python setup.py install, however, i cannot run the package locally.

Here is my package structure:

├── Dockerfile
├── package
│   ├── __init__.py
│   ├── script1.py
│   ├── script2.py
│   ├── main.py
├── setup.py

Here is the import setup in main.py:

from package.script1 import Class
from package.script2 import function

This works great if I install the package and then import package, but I cannot run python package/main.py locally or I get ModuleNotFoundError: No module named 'package'

Note: __init__.py is empty.

Thank you so much for any and all help :)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source