Probably nltk
is not in your requirements.txt
file?
ok after adding it working fine on streamlit but when deployed on heroku is giving same error,
what could be the reason ?
Deployment on Heroku is afaik a bit different.
I don’t use it, but there are some threads and tutorials out there, just search for Heroku here in the forum.
thanks for the solution
This issue remains in this case: I am running in a conda env; but you can see here that the python running is looking elsewhere. this base location doesn’t have nltk installed.
- where my python is:
/Users/<username>/opt/anaconda3/envs/tstcvs/bin/python
- The error sites a diff location
2022-12-23 10:03:08.152 Uncaught app exception
Traceback (most recent call last):
File "/opt/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
exec(code, module.__dict__)
File "/Users/<username>/work/dashboard.py", line 15, in <module>
from embeddings import embed_txt, get_top_k_hits
File "/Users/<username>/work/embeddings.py", line 11, in <module>
import nltk
ModuleNotFoundError: No module named 'nltk'
so when I do: streamlit run dashboard...
how do I tell streamlit to use the version of python in the active current env? – if this needs to be its own ‘question’ let me know.
I tried what is suggested here, but because streamlit is not using the conda env the suggestion still doesn’t work for my case see link
You must first activate the environment you want to use before entering streamlit run dashboard.py
.
In your terminal, you with see your environment in parentheses at the beginning of the line if you have it correctly activated. If not, then when you streamlit run dashboard.py
it will necessarily use the base installation of Python.
Since it looks like you are using an anaconda environment,
- From Anaconda
- Click on Environments
- Click the green play button beside the correct environment
- Select Open Terminal
When the terminal opens from here, it will already have your environment activated as you’ll see with the line prefix I mentioned. Just change directories to your script if needed and you can streamlit run....
from there.
Alternatively, if you open a terminal in your project you can run the activate.bat file for your environment there, then proceed within the activated environment.
Note, if you find you are missing any packages in your environment because they were instead installed in base previously, you can also run pip install
commands from an activated environment in the terminal before you run Streamlit.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.