System-wide Streamlit installation can't be used in virtual environments

  • I want to run a Streamlit app within a virtual environment.
  • I have installed Streamlit for the base Python interpreter, and then create a new virtual environment like:
virtualenv someEnv --system-site-packages
  • Expectation is that packages installed for the base interpreter are available in someEnv
  • Some specific software is required in the virtual env, but canโ€™t be on the base interpreter. We activate someEnv and install the necessary packages like pip install somePackage. somePackage is used by the Streamlit app.
  • Executing streamlit run with someEnv activated produces a Module not found error for somePackage.
  • I can verify some package is installed by opening an interpreter and importing somePackage
  • Installing Streamlit in someEnv while it is installed for the base interpreter produces no change.
  • Uninstalling Streamlit for the base interpreter and then re-installing in someEnv allows the app to run and find somePackage correctly.

Is this expected behaviour?

Why would using a system-installed version of Streamlit in a virtual environment prevent the app from finding packages installed in a virtual environment if that virtual environment also has access to system site packages?

Any guidance would be much appreciated!

1 Like

Iโ€™m having the same issue!! So frustrating.

As a workaround, activate the virtual environment and then execute

python -m streamlit run