Deployed app overwrites pandas version specified in requirements.txt

I made a recent post about a very strange error I started having on my deployed app. At first my app would work fine, but recently I noticed that it would start breaking. My local app that runs on a virtual environment runs perfectly fine, but I have some weird pandas errors when deployed.

After a lot of debugging, I found out that the deployed version of pandas and the one specified in my requirements.txt (which is the same one in my virtual environment) file are different. My txt file has version 1.5.3 and when I st.write(pd.version) in my app locally, I see 1.5.3. However, when the app is deployed and that code is ran, it writes 2.0.1.

This is completely crashing my app. Why is this happening and can this be fixed?

st.write(pd.__version__) when app is open locally:
local

st.write(pd.__version__) when app is deployed:
deployed

requirements.txt file used for deployment:
req

2 Likes

After some digging

Seems the way Streamlit Cloud deploys apps using an older pinned version of Streamlit might need a correction? (@StreamlitTeam see amplifying information below and photos) I used OPโ€™s repo to deploy on my own Streamlit Cloud. Initially you can see in the console log that Streamlit installs all of the requirements.txt packages correctly. Then it checks if Streamlit is installed in the environment. (See Photo 1)

Since OP is using 1.18.0, it flags "Streamlit 1.18.0 is present which is incompatible with altair>=5.0.0. Installing altair 4." Instead of checking to see if altair 4. exists in the environment (which it is and specified in the requirements.txt. I even pinned altair 4.2.2 instead of OPs 4.0 since that is what it downloads to see if it would check at all.). When it installs altair 4.* it installs all dependencies. Altair calls for pandas>=0.18 which is what causes the download of pandas 2.0.1 and eventual uninstall of existing pandas 1.5.3 from OPโ€™s req.txt file installed just prior. (See Photos 1 & 2)

Suggested fix for Streamlit Cloud

If older versions of Streamlit are downloaded in req.txt and need older version of dependencies, first check if they are satisfied already in the environment. If not, raise error for conflicting pinned requirements as pip does when a conflict is found with pinned requirement and dependency requirement. (Just initial thoughts. Just wanted to raise the issue since it seems valid)

Suggested fix for OP

This does not happen if you use the newest version of streamlit. If you update to streamlit 1.22.0 it will not try to download Altair 4.* and it installs pandas 1.5.3 without uninstalling it later. Highly recommend you try to move to 1.22.0 to keep functionality of your pinned requirements and website in the mean time while this is investigated by the streamlit team. (See Photo 3)

Opening an issue for St Cloud?

I would open a GitHub Issue normally, but seems this is not a source code issue. Instead itโ€™s more of a Streamlit Cloud issue. If there is a place to open issues for the Cloud, please let me know

Photo 1

Finds old streamlit in env. Knows altair 5 will not work, but doesnโ€™t check if altair 4.* is already in env. Kicks off altair 4.2.2 download which requires pandas>=0.18. This will download pandas 2.0.1 and overwrite his pinned pandas==1.5.3

Photo 2

Uninstalls pinned version to install pandas 2.0.1 since itโ€™s not checking

Photo 3

When using newest version of streamlit it does not trigger the Altair requirement of 4.* and will not replace his pinned pandas version. May still cause issues, but might be easier temporary solution than migrating pandas from 1 โ†’ 2 due to all the depreciations that were eliminated in the move.

4 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.