Libraries in requirements file not installed when streamlit app is deployed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2025 08:31 AM
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."ImportError: Could not import openai python package. Please install it with pip install openai."
Any help will be appreciated. Thanks
- Labels:
-
Application
-
GenAI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2025 11:44 AM
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