My app runs fine in local host, but when deploying I got this error message:
Thanks for your help!
Hi @3jcn, welcome to the Streamlit community!
If I had to guess, I would suspect that pywhatkit expects to be able to open a browser, but Streamlit sharing is a “headless” server (i.e. it doesn’t have local display capabilities). So it looks for what sort of display might be available, and since there isn’t one, a KeyError
is thrown.
It does look like that’s the case:
Thanks, Randy. How’s to solve the problem?
Hi Randy,
I disabled pywhatkit to avoid that problem, but I got another. Here is the my app url, can you take a look and find out what’s wrong. I have no problems running it on localhost.
https://share.streamlit.io/3jcn/intro-physical-science-bot/main/main.py
Thanks,
ModuleNotFoundError: No module named ‘comtypes’
but two folders: ‘comtypes’ and ‘pyttsx3’ are located in my ‘/site-packages/’
It appears that comtypes
is a Windows-specific package (Streamlit sharing are Debian images). For pyttsx3
, it appears that it has some linux-specific install instructions:
If those are really the issue, then you would need to add a packages.txt
file, with each library that needs to be apt-installed on a separate line. You can see an example of using a packages.txt
file here (that example is for ODBC drivers, but the overall structure is the same):
Best,
Randy
My OS is Windows 10. I think the problem is the way “Streamlit Sharing” access local library. All required libraries are there in local “site-package” folder, that’s why app works in localhost, but somehow “Streamlit” does not find them. Could you please test my files with your computer?
In general, Python works how it works, and Streamlit sharing isn’t doing anything non-standard. When you have a requirements.txt
file, we install it the same way you might do on any other Linux machine.
What behavior are you seeing that doesn’t work? Your Streamlit sharing link appears to be running.
Best,
Randy
Thanks, Randy. The link is an example for my point: if I used:
“from keras.layers import Dense, LSTM
from keras.models import Sequential”
my app worked on localhost, but not online (module Sequential not found).
Then I modified:
“from tensorflow.python.keras.layers import LSTM, Dense
from tensorflow.python.keras.models import Sequential”
my app works for both localhost and online.
For this app: https://share.streamlit.io/3jcn/intro-physical-science-bot/main/main.py
I can’t find another way to use “pyttsx3”.
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.
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.
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.
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.