TL;DR:
Imports which locally work fine, don’t work on streamlit cloud
Hello, I have a problem with setting working directory for the project run on the community cloud. I have the following code structure and my working directory is src
because I have two parts of my application, and one of them is streamlit.
── README.md
├── requirements.txt
├── src
│ ├── some_package
│ │ ├── main.py
│ │ ├── another_file.py
│ │
│ ├── streamlit_dashboard
│ │ ├── functions
│ │ │ ├── file.py
│ │ │ ├── file1.py
│ │ │ ├── __init__.py
│ │ ├── __init__.py
│ │ ├── main_streamlit.py
│ │ └── pages
│ │ ├── __init__.py
│ │ ├── page_1.py
│ │ ├── page_2.py
│ │ └── page_3.py
In my code I have a certain structure of imports, which start from the level just under src/
, e.g.:
from some_package.another_file import foo
Locally, I run it from src/
folder level and set PYTHONPATH='.'
:
streamlit run streamlit_dashboard.main_streamlit.py
and everything works fine. However after uploading it to the cloud, to keep it working, I need to rearrange structure of imports. Just like the working directory was where main_streamlit.py
is.
I tried to set PYTHONPATH to "/mount/src/my_project_name/src"
in secrets, but it doesnt make it work.