Install Python 3 on CentOS 7

28/12/2020
In this article, I will show you how to install Python 3.x, mainly Python 3.4, Python 3.5, Python 3.6 along with PIP for Python 3.4, Python 3.5, and Python 3.6 respectively on CentOS 7. Let’s get started.

Adding Package Repository

Python 3 is not installed by default in CentOS 7. Python 3 is not available in the official package repository of CentOS 7 as well. But we can add Inline Upstream Stable (IUS) package repository on CentOS 7 to install Python 3.

First update the yum package repository cache of your CentOS 7 machine with the following command:

$ sudo yum makecache

The yum package repository cache should be updated.

Now install yum-utils package with the following command:

$ sudo yum install yum-utils

Now press y and then press <Enter> to continue.

yum-utils should be installed.

Now add the IUS package repository with the following command:

$ sudo yum install https://centos7.iuscommunity.org/ius-release.rpm

Now press y and then press <Enter> to continue.

IUS package repository should be added.

Now update the yum package repository cache again with the following command:

$ sudo yum makecache

The yum package repository cache should be updated.

Now you’re ready to install Python 3.x.

Installing Python 3.4 and PIP for Python 3.4:

Only Python 3.4:

If you want to install only Python 3.4, not PIP for Python 3.4, run the following command:

$ sudo yum install python34u

Press y and then press <Enter> to continue.

You may be asked to accept the GPG key, press y and then press <Enter> to continue.

Python 3.4 should be installed.

Python 3.4 Including PIP for Python 3.4:

If you want to install Python 3.4 and PIP for Python 3.4, run the following command:

$ sudo yum install python34u python34u-pip

Now press y and then press <Enter> to continue.

Now press y and then press <Enter> to continue.

Python 3.4 and PIP for Python 3.4 should be installed.

Now you can check whether Python 3.4 is installed correctly with the following command:

$ python3.4 -V

As you can see, it is installed and working correctly.

You can also check whether PIP for Python 3.4 is installed correctly with the following command:

$ pip3.4 -V

As you can see, it works.

Installing Python 3.5 and PIP for Python 3.5

Only Python 3.5:

You can install only Python 3.5 and leave PIP for Python 3.5 with the following command:

$ sudo yum install python35u

Now follow the steps of the Installing Python 3.4 and PIP for Python 3.4 section of the article above. Python 3.5 should be installed.

Python 3.5 Including PIP for Python 3.5:

If you want to install Python 3.5 and PIP for Python 3.5, run the following command:

$ sudo yum install python35u python35u-pip

Now follow the steps of the Installing Python 3.4 and PIP for Python 3.4 section of the article above. Python 3.5 should be installed along with PIP for Python 3.5.

To test whether Python 3.5 works, run the following command:

$ python3.5 -V

To test whether PIP for Python 3.5 works, run the following command:

$ pip3.5 -V

Installing Python 3.6 and PIP for Python 3.6

Only Python 3.6:

You can install only Python 3.6 and leave PIP for Python 3.6 with the following command:

$ sudo yum install python36u

Now follow the steps of the Installing Python 3.4 and PIP for Python 3.4 section of the article above. Python 3.6 should be installed.

Python 3.6 Including PIP for Python 3.6:

If you want to install Python 3.6 and PIP for Python 3.6, run the following command:

$ sudo yum install python36u python36u-pip

Now follow the steps of the Installing Python 3.4 and PIP for Python 3.4 section of the article above. Python 3.6 should be installed along with PIP for Python 3.6.

To test whether Python 3.6 works, run the following command:

$ python3.6 -V

To test whether PIP for Python 3.6 works, run the following command:

$ pip3.6 -V

Changing Python Version on the Fly

You can access Python 3 using python3 command.

The default version of Python 3.x used for python3 command is Python 3.4.x.

If you have multiple version of Python 3 installed, you can change it as follows:

$ alias python3=$(which python3.x

NOTE: Here x = 4, 5, or 6 for Python 3.4, Python 3.5, and Python 3.6 respectively.

Now python3 is set to use Python 3.6.x as you can see from the screenshot below.

$ python3 -V

That’s how you install Python 3 on CentOS 7. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Moodle [Part 7] – Hướng dẫn tạo bài học và thêm các nội dung vào bài học trên Moodle

Tiếp tục series hướng dẫn sử dụng Moodle. Trong bài viết này, Onet sẽ hướng dẫn bạn tạo bài...
30/12/2020

[Zabbix] Giám sát server Ubuntu 16.04 bằng zabbix-agent

Ubuntu là một hệ điều hành nguồn mở rất phổ biến hiện nay. Vì Ubuntu thuộc họ Debian do vậy...
30/12/2020

How to Set Timezone on CentOS

Timezone determines the local time of your location. Setting the correct timezone is an important task for Linux or CentOS...
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Reliable IPv4 and IPv6 Subnet Rental Services: The Perfect Solution for Global Businesses
23/12/2024

Tìm Hiểu Về Thuê Proxy US – Lợi Ích và Cách Sử Dụng Hiệu Quả
11/12/2024

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024