Cluster libraries
Cluster libraries can be used by all notebooks running on a cluster. This article details using the Install library UI in the Azure Databricks workspace.
Note
If you create compute using a policy that enforces library installations, you can’t install or uninstall libraries on your compute. Workspace admins control all library management at the policy level.
You can install libraries to a cluster using the following approaches:
Install a library for use with a specific cluster only.
Install a workspace library that has previously been defined in the workspace. See Workspace libraries.
Install a library with the REST API. See the Libaries API.
Install a library with Databricks CLI. See What is the Databricks CLI?.
Install a library using Terraform. See Databricks Terraform provider and databricks_library.
Install a library by creating a cluster with a policy that defines library installations. See Add libraries to a policy.
(Not recommended) Install a library using an init script that runs at cluster creation time. See Install a library with an init script.
When you install a library on a cluster, a notebook already attached to that cluster will not immediately see the new library. You must first detach and then reattach the notebook to the cluster.
Not all cluster access modes support all library configurations. See Compute compatibility with libraries and init scripts.
Install a library on a cluster
To install a library on a cluster:
- Click
Compute in the sidebar. - Click a cluster name.
- Click the Libraries tab.
- Click Install New.
- The Install library dialog displays.
- Select one of the Library Source options, complete the instructions that appear, and then click Install.
Important
Default behavior for the library upload UI has changed. Legacy behavior always stored libraries in the DBFS root. All workspace users have the ability to modify data and files stored in the DBFS root.
The default location for library uploads is now workspace files. Databricks recommends uploading libraries to workspace files or Unity Catalog volumes, or using library package repositories. If your workload does not support these patterns, you can also use libraries stored in cloud object storage.
| Library Source | Instructions |
|---|---|
| Upload | Load a JAR or Whl file to workspace files and install it on the cluster. See Upload a Jar, Python egg, or Python wheel. |
| File Path/ADLS | Provide the full workspace path, volume path, or URI to the library object (for example: /Workspace/path/to/library.whl, /Volumes/path/to/library.whl, or abfss://container-name@storage-account-name.dfs.core.windows.net/path/to/library.whl). See Reference an uploaded JAR, Python egg, or Python wheel. |
| PyPI | Enter a PyPI package name. See PyPI package. |
| Maven | Specify a Maven coordinate. See Maven or Spark package. |
| CRAN | Enter the name of a package. See CRAN package. |
| Workspace Library | Select a workspace library. See Workspace libraries. |
In single user access mode, the identity of the assigned principal (a user or service principal) is used.
In shared access mode, libraries use the identity of the user who installed the library.
Note
No-isolation shared access mode does not support volumes, but uses the same identity assignment as shared access mode.
Install a library using a policy
If you create a cluster using a policy that enforces library installation, specified libraries automatically install on your cluster. You cannot install additional libraries or uninstall any libraries.
Workspace admins can add libraries to policies, allowing them to manage and enforce library installations on all compute that uses the policy. For admin instructions, see Add libraries to a policy.
Uninstall a library from a cluster
Note
When you uninstall a library from a cluster, the library is removed only when you restart the cluster. Until you restart the cluster, the status of the uninstalled library appears as Uninstall pending restart.
To uninstall a library you can start from a cluster or a library:
Cluster
- Click
Compute in the sidebar. - Click a cluster name.
- Click the Libraries tab.
- Select the checkbox next to the cluster you want to uninstall the library from, click Uninstall, then Confirm. The Status changes to Uninstall pending restart.
Library
- Go to the folder containing the library.
- Click the library name.
- Select the checkbox next to the cluster you want to uninstall the library from, click Uninstall, then Confirm. The Status changes to Uninstall pending restart.
- Click the cluster name to go to the cluster detail page.
Click Restart and Confirm to uninstall the library. The library is removed from the cluster’s Libraries tab.
View the libraries installed on a cluster
- Click
Compute in the sidebar. - Click the cluster name.
- Click the Libraries tab. For each library, the tab displays the name and version, type, install status, and, if uploaded, the source file.
Update a cluster-installed library
To update a cluster-installed library, uninstall the old version of the library and install a new version.
Feedback
Submit and view feedback for