Should I always include pandas and other library versions in requirements file?

Hi all,

When I created my streamlit sharing app a few months ago I used streamlit version 0.76 and pandas version 1.2.4. I just included streamlit==0.76.0 in the requirements file because pandas is automatically included in streamlit.

Last week I noticed that my streamlit sharing app had an error with dataframe styling
(similar to this one: Strange error: unable to understand what it means - streamlit)
and I found out that the reason for it was an issue with the new pandas version 1.3.0 which was released on 2 July.

This issue has already been solved.

I repaired my streamlit sharing app by including pandas==1.2.4 in the requirements file, I also upgraded to the latest streamlit version 0.84.0.

But now I wonder if it would be better to also include all other library versions in my requirements file to avoid unexpected errors in future.
What is the recommendation?

Sibylle Engelhard

Hey @SibylleEngelhard,

As you may have guessed already, to be on the safe side you should pin the Pandas version for your app, as Streamlit downloads the most recent version higher than 0.21.0, which is not always what you want (I was bitten by this a while ago, Streamlit bumped my Pandas to 1.2.0 which would not read .xlsx files and broke my app)

You can find a bit on this in the docs:

It is best practice to pin your Streamlit version in requirements.txt . Otherwise, the version may be auto-upgraded at any point without your knowledge, which could lead to undesired results (e.g. when we deprecate a feature in Streamlit).

You can use tools like pip-tools or pipreqs to help you generate the set of versions that work with your application.

Happy Streamlitin’
Fanilo :balloon: