4Geeks chosen to deliver AI education in the Bahamas alongside Harvard, Oxford, and Columbia.See more

How to install Python Pandas with pip (Windows, Mac, Linux)

Learn how to install Pandas in Python easily on Windows, MacOS, and Ubuntu. Follow our step-by-step guide to correctly set up Pandas for data analysis.
7 min readLast updated

Short answer: To install pandas, run pip install pandas in a terminal on Windows, macOS or Linux (Ubuntu). First confirm that Python and pip are installed with python --version and pip --version. Then verify the installation with pip show pandas or by printing pd.__version__ after import pandas as pd, and update it later with pip install --upgrade pandas.

The Pandas library in Python is a very important resource for a developer when working with a large amount of data in Python. In this article, we will see how to install this library step by step on Windows, MacOS, and Ubuntu (Linux). If you are interested, try this 👆🏽 Interactive tutorial on Pandas python.

Command to install pandas:

bash
pip install pandas

Once the installation is complete, verify that pandas was installed correctly by running the following code in an integrated development environment like visual studio code.

py
import pandas as pd
print(pd.__version__) # Output: 1.5.2

The version of pandas may vary, however, it will look similar to this format.

Alternatively, if you want to know more information, you can run the following command in the terminal which will show you more detailed information about this library.

bash
$ pip show pandas

(output) in the terminal:

bash
Name: pandas
Version: 1.5.2
Summary: Powerful data structures for data analysis, time series, and statistics
Home-page: https://pandas.pydata.org
Author: The Pandas Development Team
Author-email: pandas-dev@python.org
License: BSD-3-Clause
Location: C:\Users\57320\AppData\Local\Programs\Python\Python311\Lib\site-packages
Requires: numpy, python-dateutil, pytz

This information may vary depending on the version of Pandas you have installed and in which folder you have installed it.

More details on How to Install Pandas?

To install Pandas, you must first ensure that you have Python and the pip package manager installed on your computer. To do this, you must open a terminal, then execute the following commands:

bash
$ python --version # checks if you have Python installed
 
$ pip --version # Checks if you have the pip package installed

If you do not yet have Python installed, go to the install python page, choose the version of Python you want to install, and follow the instructions.

Normally, the pip package is already installed with Python, but if for some reason it is not installed or you want to update it, you can do so with the following commands:

bash
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
$ python get-pip.py

Now that you have confirmed that you have Python and the pip package installed correctly, you can install the Pandas library on your computer by writing the following command in the terminal:

bash
$ pip install pandas

Once the installation is finished, you can verify that it was installed correctly with the command:

bash
$ pip show pandas

What is Pandas in Python?

Pandas is a Python library that allows you to analyze and manipulate data. This library is widely used in Python development in areas such as data science, Machine learning, artificial intelligence, among many others.

One advantage of Pandas is that you can integrate it with other Python libraries like NumPy. The integration of Pandas with NumPy allows you to perform data analysis and advanced mathematical operations along with data visualization more efficiently.

How to Update the Version of Pandas?

To update the Pandas library on your computer, you can do so with a very simple command, no matter if your operating system is Windows, MacOS, or Ubuntu (Linux). You can use the same command to update Pandas on any operating system.

To update Pandas, you must first open a terminal. Below is how to do it depending on your operating system.

> Windows
Press the [ windows + R ] keys and then type "cmd"
 
> MacOS
Press the [ command + space ] keys and then type "Terminal"
 
> Ubuntu (linux)
Press the [ Ctrl + Alt + T ] keys

Once you have opened the terminal, type the following commands:

py
# Verify your current version of pandas, example: 1.5.2
pip show pandas
 
# Update pandas on your computer
pip install --upgrade pandas
 
# Verify your updated version of pandas, example: 2.0.2
pip show pandas

With the command pip install --upgrade pandas, you will update Pandas on your computer to the latest stable version available. Now you will be able to access the latest features available in this library.

Conclusion

In conclusion, pandas is a very useful library when working with data in Python. This library allows you to analyze and manipulate complex data and you can integrate it with other Python libraries like NumPy for data analysis and visualization. It is a very useful tool in development areas such as Data Science, Machine Learning, and basically for any program that works with a large amount of data in Python.

If you are interested in learning more about how you can use the Pandas library in Machine Learning, I recommend visiting the tutorial on pandas for machine learning, where you will find very useful resources and explanations with code examples and video tutorials that will help you better understand this library and learn to use all the most important features it offers.

Installing Pandas with pip is the first step toward real data analysis in Python. To go further with structured projects, real datasets and mentor guidance, compare the options of a software engineering bootcamp.

Frequently asked questions

Why does the terminal say pip is not recognized when installing pandas?

The terminal cannot find the pip command, usually because the Python scripts folder is not on the PATH. Run pip through Python instead: python -m pip install pandas, or py -m pip install pandas on Windows and python3 -m pip install pandas on macOS and Linux. To fix it permanently on Windows, reinstall Python with the option to add it to PATH checked.

How do you fix ModuleNotFoundError: No module named 'pandas'?

The error means pandas was installed for a different Python interpreter than the one running the code. Install it with that same interpreter using python -m pip install pandas. In Visual Studio Code, check the interpreter selected in the status bar, and in a Jupyter notebook run %pip install pandas in a cell so it installs into the active kernel.

How do you install pandas with conda instead of pip?

In an Anaconda or Miniconda environment, run conda install pandas, or conda install -c conda-forge pandas to use the community conda-forge channel. The full Anaconda distribution already ships with pandas, so it may not need installing at all. Avoid installing the same package with both conda and pip in one environment, because each tool tracks dependencies separately.

How do you install a specific version of pandas with pip?

Add the version after two equal signs: pip install pandas==1.5.2 installs exactly that release and replaces any other version in the environment. Run pip show pandas afterwards to confirm it. To keep different projects on different pandas versions, create a virtual environment for each one with python -m venv .venv, activate it and install pandas inside it.