Feb 19 2025 · Karol Falkowski

2 ways to install packages in Jupyter Lab

Install packages in Jupyter Lab.

Many JupyterLab users find installing packages frustrating because it requires using the terminal manually, which can be time-consuming - especially for professional programmers. However, not everyone knows that packages can be installed directly from JupyterLab. In this article, I will show you two simple ways to install packages without leaving your notebook.

1. Notebook shortcut

The first method is to run a specific command directly in a notebook cell. Here is a command schema:

import sys
!{sys.executable} -m pip install <package_name>

Example with installing pandas: Installation of pandas.

If you want to install a specific version of a package, you can do that too. All you need to do is make a small change to the command we mentioned earlier:

import sys
!{sys.executable} -m pip install <package_name>==<package_version>

Example: Installation of specific pandas version.

Common mistake

I have decided to mention the most common mistake made during installation packages from JupyterLab - wrong command syntax:

# wrong command
!pip install numpy

You may wonder why this is incorrect. The answer is simple – it might install the package in the wrong environment, which can cause problems. To avoid this, use the command mentioned earlier.

2. Jupyter Package Manager

If you want to save even more time, you can use the Jupyter Package Manager - an open source extension for JupyterLab. It lets you install any package without writing any code. Here’s how to use it:

Installation

You can install the extension using following command:

pip install jupyter-package-manager

or download it from GitHub: https://github.com/mljar/package-manager

Open Jupyter Package Manager

After installation, a new icon should appear on the sidebar:

Jupyter Package Manager on the sidebar.

Go to Install Package

Click the package icon in the top-right corner to open the Install Package section.

Go to Install Package section.

Install the package

Now, just type the package name in the input field and confirm the installation by clicking the Install button.

A confirmation message will let you know when the installation is complete:

Confirmation message appearance.

This extension and many others are available in MLJAR Studio - powerful Data Science tool that saves you time while coding with the help of an AI assistant and other features.

Get more information here: https://mljar.com/

Conclusion

In conclusion, installing packages in JupyterLab doesn’t have to be a frustrating process. You can easily run commands directly in your notebook to install packages or use the Jupyter Package Manager extension for a more user-friendly experience. For more tools and features, take a look at MLJAR Studio to improve your coding experience. See you!

Become a Data Science wizard, today!

Forget about Python problems, just do your work.

MLJAR Studio