Issues with processing python dependencies in Streamlit Cloud

Hi,
I’m deploying a streamlit app for the first time. Up until now, I have developed the app locally and everything was working fine. To deploy the app I pushed the python code, including the requirements.txt file for the python dependencies I used in the project. However, upon deployment the dependencies in the requirements.txt file are not being installed. I doublechecked if I have misspelled the file, placed it in a bad location (it is placed in the root of my repo where also streamlit’s app.py resides).

To check whether this is an issue with a specific dependency, I listed the installed python packages using

import streamlit as st
import os
result = os.popen('pip list').read()
st.code(result, language=None)

I got:

As you can see, none of the packages in requirements.txt (see below) are insalled

pypdf==3.16.1
PyYAML==6.0
openai

When I try to install the requirements.txt locally, everything also runs fine.

Am I missing something here? Thanks for any responses in advance.

Please share a link to your public github repo.

Thank you for the prompt response. The repo was previously private (not sure if that can affect the deployment in this case).

Where does this assumption come from? What is the error message?

I suspect that the output may be misleading. Maybe the packages are stored under a different user or path that pip does not know. Streamlit itself is not listed, but the app obviously works! What happens if you add for example import openai to the code, does this work?

The requirements look fine to me, I also tried them briefly in a docker container. This should theoretically also work on streamlit cloud.
Therefore, the question again: What is the specific error or error message?

Sorry for not specifying the exact error message. The specific error message is:

ModuleNotFoundError: No module named 'openai'

However, openai is listed in requirements.txt.

  • I would add streamlit to the requirements as well.
  • Have you tried a “reboot” of the app?
  • Which python version are you using locally?
  • Which python version do you have selected on streamlit cloud?

Rebooting the app solved my issue. I must have changed the requirements after first loading the app. Thanks for your help.

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