> ## Content Index
> Fetch the complete content index at: https://datascientyst.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to Install Python and Pandas on Linux
- URL: https://datascientyst.com/install-python-pandas-linux/
- Published: 2021-12-08T09:37:36.000Z
- Updated: 2022-02-01T21:20:18.000Z
- Author: John D K
- Tags: Installations

## 1\. Overview

In this tutorial, we'll introduce **different methods for installing Pandas and Python on Linux**. Then, we'll briefly compare the methods. Finally, we'll show how to manage multiple Python/Pandas versions on Linux.

As a prerequisite to each method, we need

- minimal ternimal knowledge
- non-root user with sudo privileges

The instructions described below have been tested on Linux Mint 19 and 20.

## 2\. Install Python on Linux / Ubuntu

Python is a widely-used general-purpose, powerful, mature and high-level programming language. It is easy to learn and has a huge community. Python is one of the most liked and wanted languages according to: [stackoverflow - Python is the most wanted language for its fifth-year](https://insights.stackoverflow.com/survey/2021?ref=datascientyst.com#most-loved-dreaded-and-wanted-language-love-dread)

Most Linux systems have pre-installed Python on their machine. You can check your Linux by simple command:

```python
python --version
python3 --version

```

result:

```
Python 2.7.17
Python 3.6.9

```

In 2021 Python 3 is the only one which needs to be used - Python 2 was deprecated.

### 2.1\. Install Python by apt-get

Most of the Linux distros offer Python packages which can be installed simply by:

```bash
sudo apt-get install python3.8

```

Confirm the disk space prompt and wait for the installation

To search for other Python packages and versions you can use:

```bash
apt-cache search python3

```

or filtering the results: `apt-cache search python3 | grep Interactive`:

```
python3.6-venv - Interactive high-level object-oriented language (pyvenv binary, version 3.6)
python3.7 - Interactive high-level object-oriented language (version 3.7)
python3.7-venv - Interactive high-level object-oriented language (pyvenv binary, version 3.7)

```

### 2.2\. Download and install latest Python from python.org

If we want to use the latest and greatest version of Python, often manual installation is the way to go. This means downloading the package from the [Python site](https://www.python.org/downloads/source/?ref=datascientyst.com).

Once the selected version is downloaded for example: `Python-3.10.1.tar.xz` you can extract it by:

```bash
tar -xf Python-3.10.1.tar.xz

```

Next you need to open the extracted folder:

```bash
cd Python-3.*

```

Start the configuration by:

```python
./configure

```

Finally install Python by:

```python
sudo make altinstall

```

**Note:** 

Important note: In order to prevent damage on your Linux system use \`altinstall\` instead of \`install\`.

### 2.3\. Verify the installation

Finally the installation can be verified by next commands: `python3.8` or `which python3.8` result:

```
/usr/local/bin/python3.8

```

### 2.4\. Create a virtual environment (optional)

Python offers a powerful package system `venv` which helps separate different Python packages. In simple words, you can create several virtual environments in multiple Pandas versions:

- pandas 1.3.4
- pandas 1.0.0

To create new virtual environment called `pandas1`:

- create folder for your virtual environments ( or select existing one)
- Run command: `python3.8 -m venv pandas1`
- activate the environment by:

```bash
cd pandas1
source bin/activate

```

Once environment is activated you will see change in the terminal:

```python
(pandas1) $ deactivate

```

The command above deactivates the environment.

## 3\. Install Pandas on Linux

### 3.1\. Install Pandas by Pypi

Next step is to install Pandas. The most popular way of installing Pandas is by running:

```python
pip install pandas

```

You can find more information for Pandas on: [pandas - pypi.org](https://pypi.org/project/pandas/?ref=datascientyst.com).

### 3.2\. Install Pandas by Anaconda

If you like to use alternative installation methods you can check the official docs: [Installation](https://pandas.pydata.org/pandas-docs/stable/getting%5Fstarted/install.html?ref=datascientyst.com).

For example Pandas is part of [Anaconda](https://docs.continuum.io/anaconda/?ref=datascientyst.com) \- so if you install Anaconda on your system you will get Pandas:

- download the [Anaconda installer for Linux](https://www.anaconda.com/download/?ref=datascientyst.com#linux)
- Verify data integrity with SHA-256\. (optional but highly RECOMMENDED step)
- Install Anaconda:

```bash
bash ~/Downloads/Anaconda3-2020.02-Linux-x86_64.sh

```

follow the instructions or check for more details: [Installing Anaconda on Linux](https://docs.continuum.io/anaconda/install/linux/?ref=datascientyst.com)

### 3.3\. Verify Pandas installation

Finally you can test Pandas installation by running next commands:

```bash
pip freeze | grep pandas

```

result will be:

```bash
pandas==1.3.2

```

## 4\. Conclusion

To summarize, in this article, we've seen examples of installing Python and Pandas from a PPA and manually. We've briefly explained these installation methods.

And finally, we've seen how to manage multiple Python/Pandas installations on Ubuntu systems with different package versions.