Install Python package using Jupyter Notebook
Last Updated :
12 Jul, 2025
Jupyter Notebook is an open-source web application that is used to create and share documents that contain data in different formats which includes live code, equations, visualizations, and text. Uses include data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more.
Jupyter has support for over 40 different programming languages and
Python is one of them. Python is a requirement (Python 3.3 or greater, or Python 2.7) for installing the Jupyter Notebook itself.
Refer to the following articles for the installation of the Jupyter Notebook.
In Jupyter everything runs in cells. It gives options to change the cell type to markup, text, Python console, etc. Within the Python IPython console cell, jupyter allows Python code to be executed.
Installing Python Library in Jupyter
Using ! pip install
To install Python libraries, we use pip command on the command line console of the Operating System. The OS has a set of paths to executable programs in its so-called environment variables through which it identifies directly what exactly the pip means. This is the reason that whenever pip command can directly be run on the console.
In Jupyter, the console commands can be executed by the '!' sign before the command within the cell. For example, If the following code is written in the Jupyter cell, it will execute as a command in CMD.
! echo GeeksforGeeks
Output
Similarly we can install any package via jupyter in the same way, and it will run it directly in the OS shell.
Syntax:
! pip install [package_name]
Example: Let's install NumPy using Jupyter.

But using this method is not recommended because of the OS behavior. This command executed on the current version in the $PATH variable of the OS. So in the case of multiple Python versions, this might not install the same package in the jupyter's Python version. In the simplest case it may work.
Using sys library
To solve the above-mentioned problem, it is recommended to use
sys library in Python which will return the path of the current version's pip on which the jupyter is running. sys.executable will return the path of the Python.exe of the version on which the current Jupyter instance is
Syntax:
import sys
!{sys.executable} -m pip install [package_name]
Example:

By the above code, the package will be installed in the same Python version on which the jupyter notebook is running.
Similar Reads
Installing Python yfinance in Jupyter Notebook Jupyter Notebook has the capability to seamlessly integrate with various Python libraries, including yfinance, which is used for fetching financial data. Installing yfinance in a Jupyter Notebook allows you to access stock market data directly from within your notebook environment, enabling dynamic
3 min read
Install OpenCV on Jupyter Notebook With Jupyter Notebook, users can create and share documents with live code, equations, visualizations, and narrative text in an interactive computing environment. An open-source software library for computer vision and machine learning is called OpenCV (Open Source Computer Vision Library). When com
4 min read
How to Install PySpark in Jupyter Notebook PySpark is a Python library for Apache Spark, a powerful framework for big data processing and analytics. Integrating PySpark with Jupyter Notebook provides an interactive environment for data analysis with Spark. In this article, we will know how to install PySpark in Jupyter Notebook.Setting Up Ju
2 min read
Update Jupyter Notebook to the Latest Python Version To take advantage of the latest features and improvements in Python, it is important to keep your Jupyter Notebook updated with the latest Python version. This article will guide you through the process of updating Jupyter Notebook to the latest Python version.Note: Let's say if we want to Download
3 min read
Using Jupyter Notebook in Virtual Environment In this article, we are going to see how to set Virtual Environment in Jupyter. Sometimes we want to use the Jupyter notebook in a virtual environment so that only selected packages are available in the scope of the notebook. To do this we have to add a new kernel for the virtual environment in the
2 min read
How to Install BeautifulSoup in Jupyter Notebook Installation of BeautifulSoup on Jupyter Notebook is quite easy, and you will be all set for excellent web scraping and data extraction. It is a Python library that makes HTML and XML dealing with web data. It will help you get up and running with BeautifulSoup inside your Jupyter Notebook, so you c
4 min read