cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Generative AI
Explore discussions on generative artificial intelligence techniques and applications within the Databricks Community. Share ideas, challenges, and breakthroughs in this cutting-edge field.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Libraries in requirements file not installed when streamlit app is deployed

data_scientist3
New Contributor II

I deployed a streamlit app on Databricks cluster but the libraries in the requirments.txt file were not installed when the app is deployed. I'm getting this error when a function that uses OpenAI is called."ImportErrorCould not import openai python package. Please install it with pip install openai."

Any help will be appreciated. Thanks

1 REPLY 1

stbjelcevic
Databricks Employee
Databricks Employee

Hi @data_scientist3 ,

Would you share how you deployed the Streamlit app (Databricks Apps vs running Streamlit from a notebook/job cluster) and your clusterโ€™s Databricks Runtime version? Thatโ€™ll help me tailor the exact steps to your setup.

Option 1: If you deployed a Databricks App (Streamlit app via Apps)

  • Ensure a requirements.txt is included at the root of your appโ€™s source code. Apps resolve dependencies from that file when the app is deployed; redeploy after updating it.

Option 2: Install requirements.txt to the cluster (workspace files)

If your requirements.txt is in the Databricks workspace, install it as a cluster library:

  • Upload or locate the requirements.txt in Workspace files (Workspace > Import).

  • Compute > your cluster > Libraries > Install new > Source: Workspace > select the requirements.txt path and Install.

  • Requirements-file installs are supported in Databricks Runtime 15.0+ (for workspace files). If youโ€™re on an older runtime, use PyPI or volumes instead.

Option 3: Install directly from PyPI to the cluster

If you just need OpenAI, install it from PyPI:

  • Compute > your cluster > Libraries > Install new > Source: PyPI > Package: openai==1.55.3 (or your required version) > Install

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local communityโ€”sign up today to get started!

Sign Up Now