Hi all,
I noticed this question was asked multiple time, yet I’m still not sure how to solve my problem.
I have a python tool and I added a Streamlit interface to call it via subprocess,
this flow is working fine when running Streamlit locally, yet when trying to deploy it I’m getting “ModuleNotFoundError: No module named ‘numpy’” ,
I have numpy in the requirement.txt file and I can see in the log all dependencies are being installed correctly.
I set the numpy version in the requirement file numpy==2.1.2, I added a runtime.txt to set the python version python-3.12 , try rebooting, delete and redeploy, nothing worked.
I replace all numpy usage in the tool, just to get the same issue now with peewee
“ModuleNotFoundError: No module named ‘peewee’”
Your deployed app runs in a virtual environment and you need to make sure the tool runs in the same environment. How to do that depends on the tool and how it needs to be called.
If you are the developer of the tool, I suggest you refactor it so that it can be used as a library and you don’t have to use subprocess.
Hi Goyo, calling it not as a subprocess solved the issue yet created a new issue.
all the imports and classes init I had in my tool are now get called only once, while my tool is build under the assumption that each instantiation of the tool all get re-initialized, and now I’m getting multiple failures from multiples places when I rerun the tool from streamlit.
all the singletons are holding values from previous run, a lists that was supposed to get initialized at init is now get leftovers from prev tests…
is there a solution for that? should I reload my modules each time?
Streamlit it now my main usage, so I’m a bit hesitate from entering mage restructure
Sure, there must be a solution. You should be able to change your code to make it call the import and classes init as many times as needed or work without that assumption.
Hi, I’m encountering the same issue deploying my app on Streamlit Cloud. Specifically when trying to import the ‘polars’ library in my app, it always fails. I’ve tried multiple solutions suggested in the community, but none have worked so far.
Here’s the error message displayed in the app:
ModuleNotFoundError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you’re on Streamlit Cloud, click on ‘Manage app’ in the lower right of your app).
Traceback:
File "/mount/src/house-price-prediction/Home.py", line 21, in <module>
page.run()File "/home/adminuser/.conda/lib/python3.12/site-packages/streamlit/navigation/page.py", line 303, in run
exec(code, module.__dict__)File "/mount/src/house-price-prediction/Get_Started/2_House_Query.py", line 3, in <module>
import polars as pl
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.