Jupyter Notebook is a web-based application that helps us to create Python notebooks and write our code there. Unlike other IDE or text editors, Jupyter Notebook does not have any terminal from where you can install modules. However, to install the module on Jupyter Notebook, you need to run the command inside the cell. In this short article, we will discuss how we can install pandas on Jupyter Notebook using different methods. Moreover, we will also import the Python module to check the installed version.
Installing Pandas on Jupyter Notebook
A Jupyter Notebook does not have any terminal from where you can install the modules. However, the Jupyter Notebook consists of cells and each cell can be used to run a block of code.
This is the interface of the Jupyter Notebook. Now, let us see how we can install pandas on Jupyter Notebook.
Method-1: Installing Pandas on Jupyter Notebook
One method to install the Pandas module on Jupyter Notebook is to use the pip command as we do for other modules as well.
Open the Jupyter Notebook and type the following command in the cell of the notebook and run it.
!pip install pandas
It will take a few seconds to complete the installation process.
Method-2: Using Conda Command
If you are using anaconda distribution to run the Jupyter Notebook then you can use the conda command to install the Pandas on the Jupyter Notebook.
Open the terminal and type the following commands:
conda install pandas
Once the installation is complete, you can then open the Jupyter Notebook and import the Pandas module.
Method-3: Creating a Virtual Environment
# creating virtual environment !python -m venv myenv # activating virtual environment !source myenv/bin/activate
The next step is to install the pandas using the pip command.
!pip install pandas
Once the installation process is complete, you can then import the Pandas module.
Method-4: Using the Requirements.txt File
A requirement.txt python file is a type of file that usually stores information about all the libraries, modules, and packages which are specific to the project that is used while developing a particular project. In the requirement.txt file, you can put the name of the pandas module along with its version and then run the following command which will install all the modules that are listed in the requirements.txt file.
!pip install -r requirements.txt
Hopefully, these methods will help you to install Pandas on Jupyter Notebook.
Importing Pandas Module in Jupyter Notebook
Once you have successfully installed the Pandas module on your Jupyter notebook, we can then import the Pandas module and then check the version.
#importing pandas import pandas as pd # checking the version print(pd.__version__)
As shown we have installed Pandas version 1.5.3 on our system.
In this short article, we discussed how we can install Pandas on Jupyter Notebook using 4 different methods. If you are new to Jupyter Notebook and Python programming, then you can use any of the given 4 methods for the installation of any other modules as well.