Before you proceed to install pandas package make sure you have Python or Anaconda installed and have set the environment variables to access python/pip/pip3 commands from the command line, shell, or terminal based on OS you are using.
In order to check if pandas is already installed, use
pip list command to get the list of the package installed. If you don’t have Pandas installed then this command doesn’t list it. You can also use
pip3 list command if you have pip3 installed. if you already have Pandas installed but it is an old version, you can upgrade Pandas to the latest or to a specific version using
python -m pip install --upgrade pip.
You can install the python pandas version either using PyPi & Conda.
PyPI is a Python package repository for third-party libraries, you can use the pip (Python package manager) command that comes with python to install third-party packages from PyPI. Using pip you can install/uninstall/upgrade/downgrade any python library that is part of Python Package Index. If your pip is not up to date, then upgrade pip to the latest version.
Conda is the package manager that the Anaconda distribution is built upon. It is a package manager that is both cross-platform and language agnostic (it can play a similar role to a pip and virtual environment combination).
1. Install pandas Using pip On Windows
As I said above you can install pandas to the latest version in different ways depending on how you have installed python, below I have explained using pip and conda commands on windows.
1.1 Installing from PyPi using pip Command
Before you use this, you need to have python installed. If you don’t have python installed then follow Install python pandas on windows
# Install pandas using pip pip install pandas (or) pip3 install pandas
This should give you output as below. In case if you get
'pip' is not recognized as an internal or external command error, you need to set the python installed location to PATH.
To check what version of pandas installed use
pip list or
pip3 list commands.
1.2 Installing pandas using conda (Anaconda)
If you have Anaconda distribution installed to run pandas, then open the Anaconda command prompt and use
conda install pandas to install Python pandas latest version. In case you get
'conda' is not recognized as an internal or external command error, you need to set the conda installed location to PATH.
# Install pandas using conda conda install pandas
In case if you wanted to install a specific pandas version
# Install pandas to a specific version conda install pandas=0.20.3
If you wanted to install pandas after creating the Conda environment then run the following commands
conda create -n env_name python activate env_name conda install pandas
2. Install pandas on Linux
On Linux, you can either use above mentioned commands pip & conda) or use the Linux distribution package manager to install python pandas, so depending on the flavor of Linux you are using the command would change.
2.2 Use apt-get on Ubuntu or Debian
# Install pandas using apt-get sudo apt-get install python3-pandas
I have to use
sudo to run the above command as root.
2.3 Using yum on Centos/RHEL
# Install pandas using yum yum install python3-pandas
On Linux distribution you may not find all pandas versions hence, the recommended approach would be using
3. Install pandas on Mac OS
On Mac OS, you can use either pip or conda to install pandas.
# Install pandas using pip or pip3 sudo pip install pandas or sudo pip3 install pandas
If you are not the root user then use
sudo as by default python packages are installed in the system directory where you may not have permission to write files. If you wanted to install to a specific user then use
pip install --user pandas
In this article, I have covered different ways to install python pandas on Windows, Linux, and Mac OS. It is recommended to use either pip or conda if you are using Anaconda distribution to install pandas.
- How to Check pandas Version?
- How to Upgrade pandas to Latest Version?
- How to Upgrade Python pip to Latest Version?
- Install Pandas on Windows Step-by-Step
- How to Install Anaconda & Run Jupyter Notebook
- Install Python Pandas on Windows, Linux & Mac OS
- Create Pandas Series in Python
- How to Transpose() DataFrame in Pandas?