Compute-scoped libraries

Cluster libraries can be used by all notebooks and jobs 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 on a cluster

To install a library on a cluster:

  1. Click compute icon Compute in the sidebar.
  2. Click a cluster name.
  3. Click the Libraries tab.
  4. Click Install New.
  5. The Install library dialog displays.
  6. Select one of the Library Source options, complete the instructions that appear, and then click Install.

Important

Libraries can be installed from DBFS when using Databricks Runtime 14.3 LTS and below. However, any workspace user can modify library files stored in DBFS. To improve the security of libraries in a Azure Databricks workspace, storing library files in the DBFS root is deprecated and disabled by default in Databricks Runtime 15.1 and above. See Storing libraries in DBFS root is deprecated and disabled by default.

Instead, Databricks recommends uploading all libraries, including Python libraries, JAR files, and Spark connectors, 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.

Not all cluster access modes support all library configurations. See Compute-scoped libraries.

Library source Instructions
Workspace Select a workspace file or upload a Whl, zipped wheelhouse (with *.wheelhouse.zip extension), JAR, ZIP, tar, or requirements.txt file. See Install libraries from workspace files
Volumes Select a Whl, JAR, or requirements.txt file from a volume. See Install libraries from a volume.
File Path/ADLS Select the library type and provide the full 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 Install libraries from object storage.
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.
DBFS (Not recommended) Load a JAR or Whl file to the DBFS root. This is not recommended, as files stored in DBFS can be modified by any workspace user.

When you install a library on a cluster, a notebook already attached to that cluster will not immediately see the new library. You must start a new session for the notebook to see the new library.

Note

A library that has taken more than 2 hours to install will be marked as failed.

Install libraries on dedicated compute

If your workspace enforces assigned-identity permissions on dedicated compute, only the following identities can install libraries on that compute:

  • On compute assigned to a user: that user.
  • On compute assigned to a service principal: the service principal, users with the Service Principal User role on it, workspace admins, or users with the legacy workspace-level Bind permission on it.
  • On compute assigned to a group: members of the group, or users with permission to assume the group.

You also need CAN MANAGE permission on the compute. See Compute ACLs. On compute assigned to a user or group, workspace admins aren't exempt.

If anyone else tries to install a library, the request fails with one of the following errors:

  • On compute assigned to a user: Single-user check failed: user '<caller>' attempted to run a command on single-user cluster <id>, but the single user of this cluster is '<assignee>'
  • On compute assigned to a service principal: user: <caller> does not have permission on service principal <sp> or Cannot use the cluster as user (<caller>) must have at least 'Bind' permission on the service principal (<sp>).
  • On compute assigned to a group: User <caller> is not authorized to use account group <group> assigned to workspace <id>

Libraries defined in the compute policy are exempt from this restriction. They install when the compute starts, regardless of the assigned identity. See Install a library using a policy.

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 use the cluster UI:

  1. Click compute icon Compute in the sidebar.
  2. Click a cluster name.
  3. Click the Libraries tab.
  4. 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 Restart and Confirm to uninstall the library. The library is removed from the cluster's Libraries tab.

View the libraries installed on a cluster

  1. Click compute icon Compute in the sidebar.
  2. Click the cluster name.
  3. 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.

Note

Requirements.txt files do not require uninstalling and restarting. If you have modified the contents of a requirements.txt file, you can simply reinstall it to update the contents of the installed file.