---
title: Manage dependencies using environments
description: Learn how to use environments to manage dependencies at the workload level on classic compute.
canonical_url: https://docs.databricks.com/gcp/en/compute/environments-mode
---

# Manage dependencies using environments

> [!NOTE]
> **Beta**
>
> This feature is in [Beta](https://docs.databricks.com/gcp/en/release-notes/release-types.md). Workspace admins can control access to this feature from the workspace **Previews** page using the **Environments on Standard Compute** toggle. See [ Manage workspace-level previews](https://docs.databricks.com/gcp/en/admin/workspace-settings/manage-previews.md#workspace).

On a classic compute resource that uses the **Environments** dependency mode, you manage dependencies at the workload level using [base environments](https://docs.databricks.com/gcp/en/compute/serverless/dependencies.md#base-environment) instead of installing compute-scoped libraries.

Environment settings stay isolated from compute-level changes, so workloads don't break when the compute changes underneath them. And because Databricks caches base environments, dependencies don't resolve and install at startup, so compute starts faster and avoids failures from package resolution, repository availability, or network reliability.

In a notebook attached to a classic compute resource that uses the **Environments** dependency mode, select a base environment and add dependencies from the notebook's **Environment** side pane. For job tasks, configure dependencies with a job environment specification.

## Requirements

The dependency mode setting is only available on compute that meets the following requirements:

* Databricks Runtime 19 (Beta) or above
* [Standard access mode](https://docs.databricks.com/gcp/en/compute/standard-overview.md)
* All-purpose compute or classic jobs compute

For support details, see [Limitations](https://docs.databricks.com/gcp/en/compute/environments-mode.md#limitations).

## Set the dependency mode

To create a classic compute resource that uses the **Environments** dependency mode:

1. In the workspace sidebar, click ![compute icon](https://docs.databricks.com/gcp/en/images/icons/compute-icon.png) **Compute** then open the **All-purpose compute** tab.

2. Click **Create compute**.

3. Under **Performance**, select **19 Beta** or above from the Databricks Runtime version drop-down menu.

4. Expand the **Advanced** section, then click **Dependencies**.

5. For **Dependency mode**, keep **Auto** selected to let Databricks resolve the mode, or click **Manual** and select **Environments** to set it yourself. See [Dependency mode options](https://docs.databricks.com/gcp/en/compute/environments-mode.md#dependency-mode-options).

   ![The Dependencies tab in the Advanced section of the compute creation form, with Dependency mode set to Auto and resolving to Environments.](https://docs.databricks.com/gcp/en/images/compute/environments-mode/create-environments-mode-cluster.png)

6. Configure the rest of the compute, then click **Create**.

After the compute is running, attach a notebook and configure its environment as described in [Use environments in a notebook](https://docs.databricks.com/gcp/en/compute/environments-mode.md#use-in-notebook).

### Dependency mode options

The **Dependency mode** control has two settings that determine how the mode is chosen:

* **Auto**: Databricks resolves the mode based on the compute configuration. Auto resolves to **Environments** unless the compute specifies Docker, Spark environment variables, or init scripts, in which case it resolves to **Cluster libraries**.
* **Manual**: You select **Environments** or **Cluster libraries** yourself.

When you select **Manual**, choose the mode that fits your needs:

* **Environments**: Manage dependencies at the workload level using base environments. Cluster libraries, Docker, Spark environment variables, and init scripts are disabled. Use this mode to isolate dependencies for each workload.
* **Cluster libraries**: The classic behavior. Install dependencies on the compute using cluster libraries, init scripts, or Docker. Use this mode if your workload requires any of those settings.

### Update an existing compute

If you are editing the settings for existing compute, switching to **Environments** mode is blocked if the compute has incompatible settings, such as init scripts, cluster libraries, or Docker. If you remove the incompatible settings first, you can then edit the dependency mode.

If you switch to **Cluster libraries** mode from **Environments** mode, attached notebooks retain their environment selections but those selections become inactive. If you switch the compute back to **Environments** mode, those selections become active again.

## <a id="use-in-notebook" />Use environments in a notebook

To use environments in a notebook, attach the notebook to a classic compute resource that uses the **Environments** dependency mode. After you attach the notebook, configure the notebook's dependencies from the **Environment** side pane ![environment](https://docs.databricks.com/gcp/en/images/serverless-compute/serverless-environment-icon.png).

![Configuring a notebook's environment from the Environment side pane on a classic compute resource that uses the Environments dependency mode.](https://docs.databricks.com/gcp/en/images/compute/environments-mode/environment-mode-gif.gif)

## <a id="base-environment" /> Select a base environment

A base environment determines the pre-installed libraries and environment version available for your notebook. The **Base environment** selector in the **Environment** side pane is where you choose your environment. Databricks recommends using the latest version to get the most up-to-date notebook features. To see details on each environment version, see [Environment versions](https://docs.databricks.com/gcp/en/release-notes/serverless/environment-version/index.md).

The **Base environment** selector includes the following options:

* **Standard**: The default base environment with Databricks-provided libraries.
* **ML**: A base environment with the Python and system packages from Databricks Runtime for Machine Learning pre-installed.
* **More**: Expands to show additional options:
  * Previous versions of Standard and ML environments.
  * **Custom**: Specify a custom environment using a YAML file.
* **Workspace environments**: Lists all compatible base environments configured for your workspace by workspace admins.

### <a id="add-dependencies" /> Add dependencies to the notebook

Databricks caches your notebook's virtual environment, so dependencies don't reinstall every time you reopen a notebook or resume after inactivity.

To individually install a dependency:

1. In the **Dependencies** section, enter the path of the dependency in the field then click **+Add dependency**. You can specify a dependency in any format that is valid in a [requirements.txt](https://pip.pypa.io/en/stable/reference/requirements-file-format/) file. Python wheel files or Python projects (for example, the directory containing a `pyproject.toml` or a `setup.py`) can be located in workspace files or Unity Catalog volumes.
   * If using a workspace file, the path should be absolute and start with `/Workspace/`.
   * If using a file in a Unity Catalog volume, the path should be in the following format: `/Volumes/<catalog>/<schema>/<volume>/<path>.whl`.

2. Click **Apply** to install the dependencies and restart the Python process.

> [!IMPORTANT]
>
> Do not install PySpark or any library that installs PySpark as a dependency on your notebooks. Doing so will stop your session and result in an error. If this occurs, remove the library and reset your environment.

To view installed dependencies, click the **Installed** tab in the **Environment** side pane. Open the pip installation logs for the notebook environment by clicking **pip logs** at the bottom of the pane.

## <a id="use-in-job" />Use environments in a job

For job tasks that run on a classic compute resource that uses the **Environments** dependency mode, configure dependencies with a job environment specification. A job environment specifies a base environment and any additional dependencies that one or more tasks can reference.

To configure an environment for a job task, complete the following steps:

1. Create or edit a task in a job.
2. Under **Compute**, select an existing classic compute resource that uses the **Environments** dependency mode, or add classic jobs compute.
3. If you add classic jobs compute, expand **Advanced**.
4. Click **Dependencies**.
5. For **Dependency mode**, select **Manual** and **Environments**, or keep **Auto** if it resolves to **Environments**.
6. Under **Environment and Libraries** in the task configuration, configure an environment for the task. See [Configure environment for job tasks](https://docs.databricks.com/gcp/en/compute/serverless/dependencies.md#libraries) for the options available to each task type.

Tasks that run on a classic compute resource that uses the **Environments** dependency mode do not support the **Dependent libraries** task setting. Add dependencies to the environment instead.

## Limitations

The **Environments** dependency mode supports Python workloads and dependencies in interactive notebooks and job tasks. The following limitations apply:

* Spark JAR tasks are not supported on a classic compute resource that uses the **Environments** dependency mode.
* Running `%scala` code fails.
* All standard access mode limitations apply, including no support for R. See [Standard compute requirements and limitations](https://docs.databricks.com/gcp/en/compute/standard-limitations.md).

### Incompatible settings

When **Environments** dependency mode is enabled, the following compute settings are disabled:

* Docker (Databricks Container Services)
* Spark environment variables
* Init scripts
* Cluster libraries
