All,
I am trying to figure out what is the best way to structure my package to be able to build streamlit apps within my package. I tried to follow different resources like (Structuring Your Project — The Hitchhiker's Guide to Python) while setting up the structure and it largely works fine until I attempted to start adding streamlit apps. The closest example that explains my issue is here (python - 'Attempted relative import in non-package' although packages with __init__.py in one directory - Stack Overflow)
Here is a high level overview of my package:
Package_Name
docs
examples
toolbox
tool_1.py
tool_2.py
tool_1_app.py
utils.py
enumerations.py
tests
test_tool_1.py
test_tool_2.py
configuration.py
environment.yml
README.md
Until, I attempted tool_1_app.py which is the streamlit app, everything worked fine. But, when I launch tool_1_app.py
I get a ModuleNotFoundError
indicating that toolbox
is not in the path. I can probably add the path using sys.append('../')
, however, I would like to understand how I can avoid that by structuring my package better. Any help is appreciated.
Thanks
Uday