I am having quite a hard time deploying an app through AWS CDK. I have requirements.txt, and do “import xxx” in my .py files. I even specify versions of st-pages in requirements.txt. The app is working fine on my remote desktop. This is the error I keep receiving:
ModuleNotFoundError: No module named 'st_pages'
Traceback:
File "/opt/program/peru-virtual-env/.venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/exec_code.py", line 88, in exec_func_with_error_handling
result = func()
^^^^^^File "/opt/program/peru-virtual-env/.venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 579, in code_to_exec
exec(code, module.__dict__)File "/opt/program/peru-virtual-env/lib/streamlit_app/main.py", line 10, in <module>
from st_pages import Page, add_page_title, get_nav_from_toml
I have read many posts related to ModuleNotFoundError but still couldn’t find a solution for my error. Any idea how I could resolve this please?
That works in the Community Cloud but that is not a Streamlit feature. I think that in this case, you need to manage the app dependencies yourself before running the app, for example, doing pip install -r requirements.txt before streamlit run my_app.py.
The app is running fine locally (or in my remote desktop), but it throws error when I deploy it.
I commented out st_pages and removed functions using st_pages, but now it throws another similar error for Openpyxl:
File "/opt/program/peru-virtual-env/.venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/exec_code.py", line 88, in exec_func_with_error_handling
result = func()
^^^^^^
File "/opt/program/peru-virtual-env/.venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 579, in code_to_exec
exec(code, module.__dict__)
File "/opt/program/peru-virtual-env/lib/streamlit_app/main.py", line 14, in <module>
from utils.upload_parse_files import upload_file, generate_ad_audit, change_partner_name
File "/opt/program/peru-virtual-env/lib/streamlit_app/utils/upload_parse_files.py", line 13, in <module>
import openpyxl
I checked the location of Openpyxl using typing “pip show openpyxl”, it returned:
“~. CDK/src/streamlit_app/env/lib/python3.11/site-packages’”
I also checked “where python”, it returned: “~.CDK/src/streamlit_app/env/bin/python”.
Would it be possible that Openpyxl wasn’t installed for python, but for python 3.11? However, other libraries (e.g. streamlit )are installed in the same location in “python3.11/site-packages” as openpyxl and the deployment didn’t throw errors for that.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.