Last modified: May 26, 2025 By Alexander Williams

Install Python Packages in Jupyter Notebook

Jupyter Notebook is a popular tool for data science and Python programming. Installing Python packages in Jupyter Notebook is easy. This guide will show you how.

Prerequisites

Before installing packages, ensure you have Python and Jupyter Notebook installed. If not, check our guide on Install Python on Ubuntu in 5 Steps.

You should also have pip, Python's package installer. Most Python installations include pip by default.

Install Packages Using pip in Jupyter

The easiest way to install packages is using the pip command inside a Jupyter Notebook cell. Here's how:


# Install a package using pip
!pip install numpy

The exclamation mark ! tells Jupyter to run the command in the system shell. This works like running pip in the terminal.

Install Packages with Conda

If you use Anaconda, you can install packages with conda:


# Install a package using conda
!conda install numpy

Conda is great for managing environments. For more on environments, see Install Multiple Python Versions with pyenv.

Check Installed Packages

To see what packages are installed, use:


# List installed packages
!pip list


Package    Version
---------- -------
numpy      1.21.0
pandas     1.3.0

Install Specific Versions

Sometimes you need a specific package version. Specify it like this:


# Install specific version
!pip install numpy==1.20.0

This ensures compatibility with your project.

Install from Requirements File

For multiple packages, use a requirements file:


# Install from requirements.txt
!pip install -r requirements.txt

This is useful for sharing projects. Learn more in our How to Install Python Wheels guide.

Install Development Versions

To install the latest development version from GitHub:


# Install from GitHub
!pip install git+https://github.com/user/repo.git

Common Issues

If you get permission errors, try adding --user:


# Install for current user
!pip install --user package_name

For environment issues, consider using virtual environments.

Conclusion

Installing Python packages in Jupyter Notebook is straightforward. Use !pip install for most cases. For complex projects, use requirements files or conda.

Remember to check installed packages and versions. This helps avoid conflicts. Happy coding!