2 ways to delete packages in Jupyter Lab

Many JupyterLab users struggle with removing packages because they think it can only be done through the terminal. This can be annoying and slow, especially for busy programmers. But did you know you can delete packages directly from JupyterLab? In this article, I will show you two easy ways to remove packages without leaving your notebook.
1. Notebook shortcut
The first way is to run a special command inside a notebook cell. Here is the basic command format:
import sys
!{sys.executable} -m pip uninstall <package_name> --yes
Example of pandas deletion:

Common mistake
One of the biggest mistakes when deleting a package in Jupyter is forgetting to add --yes. Here’s what happens if you skip it:

As you can see it causes never-ending process because you technically can't confirm the deletion. This happens because the --yes parameter is needed to automatically confirm it.
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. With it, you can delete any package without writing code. Here’s how to do 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:

Find the package to delete
You can scroll to find a package or use the search bar, which is much easier:

Delete the package
After you find the package you want to delete, move your mouse over it. The delete button will appear:

Now, just click on the delete button and confirm the deletion:

And that's all. The package is successfully deleted!
This extension, along with many others, is available in MLJAR Studio - a powerful Data Science tool that helps you code faster with an AI assistant and other useful features.
Get more information here: https://mljar.com/
Conclusion
Deleting packages in JupyterLab doesn’t have to be difficult or time-consuming. You can remove them using a simple command in your notebook or use the Jupyter Package Manager for an easier, no-code solution. For more tools and features, check out MLJAR Studio to enhance your coding experience. See you!