Hey,
Struggling to get basic usage going. Currently working in a venv and have the following requirements.txt
pymongo==4.2.0
streamlit==1.12.2
The code snippet
import streamlit as st
import pymongo
st.text("This is my first Mongo")
When executed with streamlit run
fails with error ModuleNotFoundError: No module named 'pymongo
’
Seems simple enough. But I can confirm when I run a simple python script in the same ENV // directory // file, pymongo exists and executes without error:
def main():
import pymongo
import streamlit
print("ok")
if __name__ == "__main__":
main()
Also when I add the line os.system("pip3 install pymongo")
into streamlit script, prior to import…
import streamlit as st
import os
os.system("pip3 install pymongo")
import pymongo
st.text("This is my first Mongo")
… terminal outputs that Requirement already satisfied: pymongo in ./ENVmongo/lib/python3.9/site-packages (4.2.0)
yet still result in the ModuleNotFoundError:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 556, in _run_script
exec(code, module.__dict__)
File "{file}.py", line 6, in <module>
import pymongo
ModuleNotFoundError: No module named 'pymongo'
Have installed/uninstalled both packages and sudo hard installed pymongo into python3.9 directory, but no changes. Also uninstalled everything and followed this thread’s instructions with no success.
Let me know what I am missing, thanks