Install libraries from workspace files
This article walks you through the steps required to upload package or requirements.txt files to workspace files and install them onto clusters in Azure Databricks. You can install libraries onto all-purpose compute or job compute.
Important
This article describes storing libraries as workspace files. This is different than workspace libraries which are deprecated.
For more information about workspace files, see Navigate the workspace.
Databricks Runtime 15.0 or above is required to upload requirements.txt files to workspace files. For full library compatibility details, see Libraries.
Load libraries to workspace files
You can load libraries to workspace files the same way you load other files.
To load a library to workspace files:
- Click Workspace in the left sidebar.
- Navigate to the location in the workspace where you want to upload the library.
- Click the in the upper right and choose Import.
- The Import dialog appears. For Import from: choose File or URL. Drag and drop or browse to the file(s) you want to upload, or provide the URL path to the file.
- Click Import.
Install libraries from workspace files onto a cluster
When you install a library onto a cluster, all notebooks running on that cluster have access to the library.
To install a library from workspace files onto a cluster:
- Click Compute in the left sidebar.
- Click the name of the cluster in the cluster list.
- Click the Libraries tab.
- Click Install new. The Install library dialog appears.
- For Library Source, select Workspace.
- Upload the library or requirements.txt file, browse to the library or requirements.txt in the workspace, or enter its workspace location in the Workspace File Path field, such as the following:
/Workspace/Users/someone@example.com/<path-to-library>/<library-name>.<ext>
- Click Install.
Add dependent libraries to workflow tasks from workspace files
You can add dependent libraries to tasks from workspace files. See Configure dependent libraries.
To configure a workflow task with a dependent library from workspace files:
- Select an existing task in a workflow or create a new task.
- Next to Dependent libraries, click + Add.
- In the Add dependent library dialog, select Workspace for Library Source.
- Upload the library or requirements.txt file, browse to the library or requirements.txt file in the workspace, or enter its workspace location in the Workspace File Path field, such as the following:
/Workspace/Users/someone@example.com/<path-to-library>/<library-name>.<ext>
- Click Install.
Install libraries from workspace files to a notebook
You can install Python libraries directly to a notebook to create custom environments that are specific to the notebook. For example, you can use a specific version of a library in a notebook, without affecting other users on the cluster who may need a different version of the same library. For more information, see notebook-scoped libraries.
When you install a library to a notebook, only the current notebook and any jobs associated with that notebook have access to that library. Other notebooks attached to the same cluster are not affected.