streamlit/streamlit

Streamlit reinstalling packages by itself causing incompatibilities

Haelios opened this issue · 4 comments

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

When deploying the app via streamlit, it runs an automatic check to see if Streamlit is already installed. It is specified in my requirements, so it should stop at that. However, since I use Streamlit == 1.14.0 for compatibility reasons with streamlit-extras, it detects that I should be using altair <5 to be compatible with streamlit as well. And so, even though altair == 4.2.2 is already installed, it reinstalls it, and with it it's dependencies, namely numpy == 1.25.0 which cause problems as it is incompatible with the latest version of the shap library.

Now I'm not sure if this is considered a bug, as everything seems to be working as intended, but I don't understand why it would reinstall altair even though it already is. And I have no idea what I can do to avoid this issue on my side.

Reproducible Code Example

No response

Steps To Reproduce

Deploy the app via streamlit using the repositery linked.

Expected Behavior

When i use the dashboard created locally via a brand new venv, everything installs and works as expected with no issues, and I can display the dashboard perfectly.

Current Behavior

Now what happens is, all the packages install properly from the requirements.txt. But after the packages installation, Streamlit runs an automatic check to verify that the Streamlit package is installed. And this follows in the logs of the app :

Checking if Streamlit is installed

2023-06-30 15:38:50.451 INFO matplotlib.font_manager: generated new fontManager

Found Streamlit version 1.14.0 in the environment

Streamlit 1.14.0 is present which is incompatible with altair>=5.0.0. Installing altair 4.*

Collecting altair<5

And so by doing that, it goes and reinstall altair < 5 even though it already is, and by doing that, reinstalls numpy == 1.25.0, which isn't compatible with shap, causing the app to fail to deploy.

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

These are the relevant packages causing the issue.

streamlit == 1.14.0
altair < 5
streamlit-extras==0.2.7
shap==0.41.0
numpy==1.23.5

Additional Information

Here's the log file with the issue

logs-haelios-projet_7_oc-main-Dashboard-streamlit_dashboard.py-2023-06-30T16_02_38.954Z.txt

Are you willing to submit a PR?

  • Yes, I am willing to submit a PR!

Not 100% sure but I think this is just normal pip behavior. If pip installs a package that requires an earlier version of a package that is already installed (here: altair 5 is already installed but streamlit 1.14 requires altair 4), it will uninstall that package and install the earlier version.

Out of curiosity, which part of streamlit-extras requires streamlit==1.14?

Not 100% sure but I think this is just normal pip behavior. If pip installs a package that requires an earlier version of a package that is already installed (here: altair 5 is already installed but streamlit 1.14 requires altair 4), it will uninstall that package and install the earlier version.

The thing is I made sure I'm already installing altair 4 before that, it's in my requirements, therefore it shouldn't reinstall it.

For the versioning, I just took what's indicated in the requirements on the streamlit-extras github.

I encountered the same issue. I have to install tensorflow 2.6 which requires numpy 1.19.5, and typing-extensions ~=3.7.4. Typing-extensions limits streamlit <=1.10.0. Since a numpy 1.25.2 has been downloaded I have to add a line as define numpy==1.19.5 in the requirements.txt. But when streamlit check the conflicts, is always re-install altair 4.2.2 and then download numpy 1.25.2 again. Even I defined altair==4.2.2 which satisfied the version requirement streamlit uninstall altair and re-install it again. This caused the numpy always be 1.25.2. Don't know how to stop streamlit check or not re-install packages.