Featured Article

Install Python Packages in Azure Databricks Notebook Easily

Kenneth Jul 13, 2026

In the realm of big data processing and analysis, Azure Databricks has emerged as a powerful, unified analytics service. It offers a collaborative Apache Spark-based analytics platform optimized for the Microsoft Azure cloud. One of its key features is the ability to install and use custom Python packages in Databricks Notebooks. This guide will walk you through the process of installing a Python package in Azure Databricks step by step.

Develop code in Databricks notebooks - Azure Databricks
Develop code in Databricks notebooks - Azure Databricks

The first step is to understand how Databricks manages Python packages. Databricks uses a file system called DBFS (Databricks File System) to store files and dependencies. Any Python package you install will be stored here. Now, let's dive into the process.

Databricks comes to Microsoft Azure
Databricks comes to Microsoft Azure

Installing Python Packages

The process of installing Python packages in Databricks is slightly different from how you would typically install them in a local environment. Databricks uses a system of cell magics that allow it to run shell commands or notebook directives.

Exploring an Alternative to Jupyter Notebooks for Python Development
Exploring an Alternative to Jupyter Notebooks for Python Development

Here's how you can install a Python package using the %pip magic:

Using %pip to Install Packages

an image of a computer screen with text and numbers on it, including the same language as
an image of a computer screen with text and numbers on it, including the same language as

The %pip magic allows you to install Python packages in your Databricks cluster. Here's how you can use it:

1. In your Databricks Notebook, open a new code cell. At the top of this cell, click on "Cell Type" and select "Magic".

2. Inside the cell, type %pip install package_name, replacing package_name with the actual name of the Python package you want to install. For example, if you want to install pandas, your command would look like this: %pip install pandas.

Python Data Structures Cheat Sheet for Beginners (Lists, Tuples, Sets & Dictionaries)
Python Data Structures Cheat Sheet for Beginners (Lists, Tuples, Sets & Dictionaries)

3. Press Shift + Enter to run the cell. Once the command is executed, the Python package will be installed in your Databricks cluster.

Verifying the Installation

To confirm that the package is installed correctly, you can import it in a new code cell and try to use it. Here's how:

How to debug inline Python code in Azure Data Explorer | Microsoft Community Hub
How to debug inline Python code in Azure Data Explorer | Microsoft Community Hub

1. Open a new code cell in your Databricks Notebook.

2. Type import package_name and press Shift + Enter. If the package has been installed successfully, you should not see any ImportError.

GitHub - Textualize/rich: Rich is a Python library for rich text and beautiful formatting in the terminal.
GitHub - Textualize/rich: Rich is a Python library for rich text and beautiful formatting in the terminal.
Python Cheat Sheet for Beginners 2026 | Python Basics, Syntax, Loops, Functions & Variables
Python Cheat Sheet for Beginners 2026 | Python Basics, Syntax, Loops, Functions & Variables
several different types of books on the same page, including one with an alligator and another with
several different types of books on the same page, including one with an alligator and another with
a diagram with the words data structure in it
a diagram with the words data structure in it
Programming Terminology Guide, Basic Python Dictionary Tutorial, How To Iterate Over A Dictionary In Python, Programming Language Terms, Python Dictionary Keys And Values, How To Create A Nested Dictionary In Python, How To Make A Nested Dictionary In Python, How To Sort Dictionary By Key In Python, Python File Methods Dictionary
Programming Terminology Guide, Basic Python Dictionary Tutorial, How To Iterate Over A Dictionary In Python, Programming Language Terms, Python Dictionary Keys And Values, How To Create A Nested Dictionary In Python, How To Make A Nested Dictionary In Python, How To Sort Dictionary By Key In Python, Python File Methods Dictionary
a poster with the names and numbers of different types of items
a poster with the names and numbers of different types of items
Announcing Support for Native Editing of Jupyter Notebooks in VS Code - Microsoft for Python Developers Blog
Announcing Support for Native Editing of Jupyter Notebooks in VS Code - Microsoft for Python Developers Blog
Python Packages For Data Science
Python Packages For Data Science
💻
💻

Remember, packages installed using %pip are only available for the current Databricks cluster. If you want to share the packages between notebooks or clusters, you'll need to use Databricks' package repository feature.

Using Databricks' Package Repository

Databricks' package repository allows you to share your installed packages across different clusters and notebooks. Here's how you can use it:

Uploading a Package to the Repository

1. Install the package using the %pip magic in a Databricks cluster, as shown in the previous section.

2. Once the package is installed, you can upload it to the package repository using the dbr marketplace upload command. You can run this command in a terminal or a Databricks Notebook using the %sh magic.

For example, %sh dbr marketplace upload /dbfs/your-repeatable-path/to/your-package.tar.gz package-name. Replace your-repeatable-path with the actual path where you stored the package, and package-name with the name you want to give to your package.

Installing a Package from the Repository

1. Open a new Databricks Notebook and create a new cell with "Magic" as the cell type.

2. Use the %sh magic to install the package from the repository. For example, %sh dbr marketplace install package-name. Replace package-name with the name of the package you uploaded.

3. Once the package is installed, you can import it in a new code cell and start using it.

Installing Python packages in Azure Databricks can greatly enhance your data analysis capabilities. By following these steps, you can install popular data science libraries like pandas, NumPy, or scikit-learn, and use them in your Databricks Notebooks.

Remember, Databricks offers a powerful and collaborative environment for big data processing and analysis. By mastering these package installation techniques, you can unlock even more potential from this powerful tool. Happy analyzing!