- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2024 08:49 PM
Dear databrick team,
I want to know if there is a method in Databricks equivalent to pip install -r requirements.txt
There are packages I want to install in this path: /Workspace/Users/xxx@domain.com/databrick_requirement.txt
I have referred to the following document: https://learn.microsoft.com/en-us/azure/databricks/libraries/notebooks-python-libraries#use-a-requir...
I executed:
%pip install -r /Workspace/Users/xxx@domain.com/databrick_requirement.txt
but it gave the following error:
Looking forward to your reply, thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2024 11:14 PM
Hi @CE ,
Yes, you can install packages from a requirements.txt file in Databricks, similar to using pip install -r requirements.txt in a local environment. However, the path you provided (/Workspace/Users/xxx@domain.com/databrick_requirement.txt) isn't directly accessible by the %pip command.
1. If you have a unity catalog available, create a Volume, upload your file to the volume and then run your pip install command like:
%pip install -r "/Volumes/<path to the file>/requirements.txt"2. If you using the old workspace without unity catalog, do similarly, but upload the file to DBFS
3. Also, instead of running %pip install within individual notebooks, a more efficient approach—especially for managing dependencies across multiple notebooks and users—is to use init scripts. This ensures that all necessary libraries are installed automatically when the cluster starts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 05:12 AM
- Generate Wheels: pip wheel -r databrick_requirement.txt -w ./wheels
- Either directly upload via the UI or use the Databricks CLI to copy the wheel files to a DBFS location.
- Install the Wheels in Databricks: Install the packages from the .whl files:%pip install /dbfs/wheels/my_package-1.0.0-py3-none-any.whl