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