Linux Administrator Miscellaneouss

Easy Steps To Install Python 3 On CentOS

The default Python version 2.7 is still same on latest CentOS 7. It is also not available in base repositories.

If you want to use python3 follow the below steps to install python3 on your system.

Run below command to setup a necessary build environment for python3 and install dependencies.

#yum-builddep python

Then download the latest python3 package form python official website “https://www.python.org/ftp/python/

DOWNLOAD AND INSTALL PYTHON3

#curl -O https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz

# tar xf Python-3.5.0.tgz
# cd Python-3.5.0
# ./configure
# make
# make install

Here default installations directory is “ /usr/local/ “. You can change it  to some another directory with “–prefix=/your/directory/

# ./configure --prefix=/your/directory/
# make
# make install

Python3 has been installed successfully.

Check python installed version.

# python3 --version
Python 3.4.5

INSTALLING PYTHON 3.4 WITH YUM COMMAND

You can install python34 with yum command using EPEL Repository.

#yum install epel-release

After installing and enabling EPEL repository install python 3.4 version.

# yum install python34
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* epel: epel.mirror.net.in
* extras: centos.excellmedia.net
* remi: fr2.rpmfind.net
* remi-php56: fr2.rpmfind.net
* remi-safe: fr2.rpmfind.net
* updates: centos.excellmedia.net
Resolving Dependencies
--> Running transaction check
---> Package python34.i686 0:3.4.5-1.el6 will be installed
--> Processing Dependency: python34-libs(x86-32) = 3.4.5-1.el6 for package: python34-3.4.5-1.el6.i686
--> Processing Dependency: libpython3.4m.so.1.0 for package: python34-3.4.5-1.el6.i686
--> Running transaction check
---> Package python34-libs.i686 0:3.4.5-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================================================
Installing:
python34 i686 3.4.5-1.el6 epel 49 k
Installing for dependencies:
python34-libs i686 3.4.5-1.el6 epel 6.8 M

Transaction Summary
=======================================================================================================================================================================
Install 2 Package(s)

Total download size: 6.8 M
Installed size: 27 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): python34-3.4.5-1.el6.i686.rpm | 49 kB 00:00
(2/2): python34-libs-3.4.5-1.el6.i686.rpm | 6.8 MB 00:06
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 980 kB/s | 6.8 MB 00:07
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : python34-3.4.5-1.el6.i686 1/2
Installing : python34-libs-3.4.5-1.el6.i686 2/2
Verifying : python34-libs-3.4.5-1.el6.i686 1/2
Verifying : python34-3.4.5-1.el6.i686 2/2

Installed:
python34.i686 0:3.4.5-1.el6

Dependency Installed:
python34-libs.i686 0:3.4.5-1.el6

Complete!

After that you will need to install matching pip. Follow the below command to install pip and setuptools.

Installing pip and setuptools:

# curl -O https://bootstrap.pypa.io/get-pip.py

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1558k 100 1558k 0 0 261k 0 0:00:05 0:00:05 --:--:-- 347k
# /usr/bin/python3.4 get-pip.py

Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100% |################################| 1.3MB 329kB/s
Collecting setuptools
Downloading setuptools-32.2.0-py2.py3-none-any.whl (477kB)
100% |################################| 481kB 205kB/s
Collecting wheel
Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
100% |################################| 71kB 899kB/s
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-9.0.1 setuptools-32.2.0 wheel-0.29.0

I hope this article will be helpful to understand how we can install Python3 on CentOS. If you have any queries and problem please comment in comment section.

Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

1 Comment

Leave a Comment