When does it become a requirement to add packages.txt file in your repo?

Hi,

Can someone please let me know when do we need to add packages.txt file when using Streamlit sharing/deployment?

I had the app working after deployment, but after adding a new library (wikipedia) in my code, it is no longer working after deployment. I get “Whoops - something went wrong! An error has been logged”.

I did a bit of research here on the threads and found that in some cases it is suggested to add packages.txt file, but I am not sure when it is needed and when it is not needed (as my app worked fine prior to me starting to use a new “wikipedia” library).

I tried adding “packages.txt” and placing just “wikipedia” under it, but then I got another error message and the app did not work either.

Here is the link to my repo:

Can someone please advise?

Thank you in advance!
Negmat

Hello @Negmat_Mullodzhanov,

To put it simply:

  • Python packages: any Python package available on PyPi should be in requirements.txt, those dependencies are installed through pip install -r requirements.txt
  • apt-get dependencies: any Debian package you normally install with apt-get install ...

Some Python packages depend on OS libraries: for example Pyspark would rely on Java JDK, or geckodriver would need Firefox. Those required OS libraries are usually documented in the project’s README.


I don’t think wikipedia here requires a OS library :thinking:. You’d see an error like ImportError: xxx: cannot open shared object file it in the black sidebar on the right.
Whenever you get a cannot open shared object file then you should suspect a missing OS library.
Are there any other errors in the sidebar? Maybe wikipedia wasn’t correctly installed and a reboot would do the work?

Have a good day,
Fanilo :balloon:

Hi Fanilo,

Thank you for your response!

What is interesting is that before adding “wikipedia” the app worked without the requirements.txt file, even though I had to pip install (in addition to wikipedia) pandas and pydeck.

The good news is that based on your advice I have added requirements.txt and placed pandas, pydeck, and wikipedia there, and now my app is working.

Have a great day!
Negmat

1 Like

Oh yeah, actually pandas/pydeck are installed with Streamlit and so are present in the base Streamlit Share image, which is why your app did not malfunction up until you wanted to add the wikipedia package :slight_smile:

Have fun Streamlitin’
Fanilo :balloon:

This makes sense!

Where can we see which packages are part of Streamlit base build?

I suspect many users who are deploying through Streamlit share are having same issues as I did not find any documentation specifying when to create requirements.txt file and what should be included there.

Thanks!

Ah yeah, maybe it’s not as visible as other sections… (it’s here, though there’s no info on pre-installed libraries, it’s just my intuition that Streamlit and its dependencies are installed by default :wink: )

Mind if I ask, how/where would you have preferred to find this information in the docs :slight_smile: ? @snehankekre will surely be interested by your thoughts.

Fanilo

1 Like

Thank you Fanilo.

Streamlit deployment process is so easy that I failed to look for/read any documentation about it.

Now I see it from your link :slightly_smiling_face:

2 Likes