Python Tutorials: Installing Python 3 on Linux, Centos, Ubuntu & Windows

Python 3 Installation in Ubuntu


$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.8
$ python3 --version

Or

$ sudo apt-get install python3.6
$ python3 --version

Default Versions of Python in CentOS


Depending on when you’re reading this or what version you’re using, the version that you have installed by default or the version that’s available in the CentOS repo might be different.

For CentOS 7:

  • Python 2.7.5 is installed by default. That version has reached its EOL years ago, so you should upgrade ASAP.
  • Python 3.6.8 is the latest version available in the CentOS 7 repos. 3.6 reached its EOL in Dec 2021, so you should upgrade ASAP.

For CentOS 8:

  • Python isn’t installed by default.
  • Python 3.9.6 is the latest version available in the CentOS 8 repos. The EOL of Python 3.9.6 is Oct 2025, so you can use that version. To install it, just run yum install python39 and that’s it. If you want to install Python 3.10 or 3.11, follow the tutorial below.

Python 3 Installation in Centos


$ sudo yum install yum-utils
$ sudo yum-builddep python3
$ python3 --version

Installing Python 3.6 on CentOS 7

sudo yum -y install wget make gcc openssl-devel bzip2-devel
cd /tmp/
wget https://www.python.org/ftp/python/3.6.12/Python-3.6.12.tgz
tar xzf Python-3.6.12.tgz
cd Python-3.6.12
./configure --enable-optimizations
sudo make altinstall
sudo ln -sfn /usr/local/bin/python3.6 /usr/bin/python3
sudo ln -sfn /usr/local/bin/python3.6 /usr/bin/python
sudo ln -sfn /usr/local/bin/pip3.6 /usr/bin/pip3
python3.6 -V
pip3.6 -V
$ sudo ln -fs /usr/local/bin/python3.6 /usr/bin/python
$ sudo ln -fs /usr/local/bin/python3.6 /usr/bin/python3

Installing Python 3.7 on CentOS 7

sudo yum -y install wget make gcc openssl-devel bzip2-devel
cd /tmp/
wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
tar xzf Python-3.7.9.tgz
cd Python-3.7.9
./configure --enable-optimizations
sudo make altinstall
sudo ln -sfn /usr/local/bin/python3.7 /usr/bin/python3.7
sudo ln -sfn /usr/local/bin/pip3.7 /usr/bin/pip3.7
python3.7 -V
pip3.7 -V
$ sudo ln -fs /usr/local/bin/python3.7 /usr/bin/python
$ sudo ln -fs /usr/local/bin/python3.7 /usr/bin/python3

Installing Python 3.8 on CentOS 7

sudo yum -y install wget make gcc openssl-devel bzip2-devel
cd /tmp/
wget https://www.python.org/ftp/python/3.8.7/Python-3.8.7.tgz
tar xzf Python-3.8.7.tgz
cd Python-3.8.7
./configure --enable-optimizations
sudo make altinstall
sudo ln -sfn /usr/local/bin/python3.8 /usr/bin/python3.8
sudo ln -sfn /usr/local/bin/pip3.8 /usr/bin/pip3.8
python3.8 -V
pip3.8 -V
$ sudo ln -fs /usr/local/bin/python3.8 /usr/bin/python
$ sudo ln -fs /usr/local/bin/python3.8 /usr/bin/python3

Installing Python 3.8 on CentOS 7

sudo yum -y install wget make gcc openssl-devel bzip2-devel
cd /tmp/
wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz
tar xzf Python-3.9.1.tgz
cd Python-3.9.1
./configure --enable-optimizations
sudo make altinstall
sudo ln -sfn /usr/local/bin/python3.9 /usr/bin/python3.9
sudo ln -sfn /usr/local/bin/pip3.9 /usr/bin/pip3.9
python3.9 -V
pip3.9 -V
$ sudo ln -fs /usr/local/bin/python3.9 /usr/bin/python
$ sudo ln -fs /usr/local/bin/python3.9 /usr/bin/python3

How to Install Python 3.10 on CentOS

yum update
yum install openssl-devel bzip2-devel libffi-devel
yum groupinstall “Development Tools”
wget https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tgz
tar -xzf Python-3.10.2.tgz
cd Python-3.10.2
./configure –enable-optimizations
make altinstall
python3.10 -V

$ sudo ln -fs /usr/local/bin/python3.10 /usr/bin/python
$ sudo ln -fs /usr/local/bin/python3.10 /usr/bin/python3

How to Install Python 3.10 on CentOS

yum update
yum install openssl-devel bzip2-devel libffi-devel
yum groupinstall “Development Tools”
wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0a4.tgz
tar -xzf Python-3.11.0a4.tgz
cd Python-3.11.0a4
./configure –enable-optimizations
make altinstall
python3.11 -V

$ sudo ln -fs /usr/local/bin/python3.11 /usr/bin/python
$ sudo ln -fs /usr/local/bin/python3.11 /usr/bin/python3

Rajesh Kumar
Follow me
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Alex
Alex
1 year ago

Doesn’t work on CentOS 7.

1
0
Would love your thoughts, please comment.x
()
x