---
title: Manage Python dependencies for pipelines
description: Install external Python dependencies in Lakeflow pipelines using the pipeline Environment settings, workspace-file modules, or cluster-scoped init scripts.
canonical_url: https://docs.databricks.com/aws/en/ldp/developer/external-dependencies
---

# Manage Python dependencies for pipelines

Lakeflow pipelines support external dependencies in your pipelines. Databricks recommends using one of two patterns to install Python packages:

1. Use the **Environment** settings to add packages to the pipeline environment for all source files in a pipeline.
2. Import modules or libraries from source code stored in workspace files. See [Import Python modules from Git folders or workspace files](https://docs.databricks.com/aws/en/ldp/import-workspace-files.md).

Pipelines that use classic compute also support cluster-scoped [init scripts](https://docs.databricks.com/aws/en/init-scripts/cluster-scoped.md). serverless Lakeflow pipelines does not support init scripts. In all cases, Databricks recommends using the **Environment** settings rather than init scripts, because external dependencies, particularly init scripts, increase the risk of issues with runtime upgrades. If your processing requires init scripts, automate testing of your pipeline to detect problems early, and Databricks recommends increasing your testing frequency.

> [!IMPORTANT]
>
> Because [JVM libraries are not supported](https://docs.databricks.com/aws/en/ldp/developer/external-dependencies.md#jvm-library-support) in pipelines, do not use an init script to install JVM libraries. However, you can install other library types, such as Python libraries, with an init script.

## <a id="python-libraries-environment" />Python libraries

To specify external Python libraries, edit the environment for your pipeline.

1. From the pipeline editor, click **Settings**.
2. Under **Pipeline environment**, select ![Pencil icon.](https://docs.databricks.com/aws/en/images/product-icons/PencilIcon.svg) **Edit environment**.
3. Click ![Plus icon.](https://docs.databricks.com/aws/en/images/product-icons/PlusIcon.svg) **Add dependency**.
4. Type the name of the dependency. Databricks recommends pinning the version of the library. For example, to add a dependency on `simplejson` version 3.19, type `simplejson==3.19.*`.

You can also install a Python wheel package from a Unity Catalog volume, by specifying its path, such as `/Volumes/my_catalog/my_schema/my_ldp_volume/ldpfns-1.0-py3-none-any.whl`.

> [!NOTE]
>
> Pipelines do not support manually restarting the Python process with [`dbutils.library.restartPython()`](https://docs.databricks.com/aws/en/libraries/restart-python-process.md). Declare all Python dependencies through the **Environment** settings rather than installing or reloading them at runtime. Using the **Environment** settings also lets pipelines reuse cached libraries across runs instead of reinstalling them on every run.

## <a id="environment-version" />Environment version

By default, the Python language version and preinstalled library set available to your pipeline come from the current Databricks Runtime channel version. See [Lakeflow pipelines release notes and the release upgrade process](https://docs.databricks.com/aws/en/release-notes/dlt/index.md) for the current versions and the per-runtime package lists.

> [!NOTE]
> **Beta**
>
> This feature is in [Beta](https://docs.databricks.com/aws/en/release-notes/release-types.md).

To pin the Python language version and preinstalled library set independently of Databricks Runtime upgrades, configure an environment version on the pipeline. While an environment version is set, Databricks Runtime upgrades don't change your Python language version or preinstalled library versions, and any external dependencies you add through the **Environment** settings are layered on top of this base. See [Configure environment versions for pipelines](https://docs.databricks.com/aws/en/ldp/developer/environment-versions.md).

## <a id="jvm-library-support" />Scala and Java library support

No, pipelines support only SQL and Python. You cannot use JVM libraries in a pipeline. Installing JVM libraries causes unpredictable behavior, and may break with future Lakeflow pipelines releases. If your pipeline uses an init script, you must also ensure that JVM libraries are not installed by the script.
