Install Python3 and pip3 on CentOS 7

CentOS 7 still have Python 2.7 as the default tool. EPEL repository comes up with Python 3. Thanks to EPEL repo. Here’s the way to setup Python 3 and pip3 on CentOS environment.

Install python34 and python-pip package.

[root@cms ~]# yum install python34 python-pip
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: mirror.pregi.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
Resolving Dependencies
--> Running transaction check
---> Package python-pip.noarch 0:7.1.0-1.el7 will be installed
--> Processing Dependency: python-setuptools for package: python-pip-7.1.0-1.el7.noarch
---> Package python34.x86_64 0:3.4.5-2.el7 will be installed
--> Processing Dependency: python34-libs(x86-64) = 3.4.5-2.el7 for package: python34-3.4.5-2.el7.x86_64
--> Processing Dependency: libpython3.4m.so.1.0()(64bit) for package: python34-3.4.5-2.el7.x86_64
--> Running transaction check
---> Package python-setuptools.noarch 0:0.9.8-4.el7 will be installed
--> Processing Dependency: python-backports-ssl_match_hostname for package: python-setuptools-0.9.8-4.el7.noarch
---> Package python34-libs.x86_64 0:3.4.5-2.el7 will be installed
--> Running transaction check
---> Package python-backports-ssl_match_hostname.noarch 0:3.4.0.2-4.el7 will be installed
--> Processing Dependency: python-backports for package: python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch
--> Running transaction check
---> Package python-backports.x86_64 0:1.0-8.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================
 Package                                                  Arch                        Version                              Repository                 Size
===========================================================================================================================================================
Installing:
 python-pip                                               noarch                      7.1.0-1.el7                          epel                      1.5 M
 python34                                                 x86_64                      3.4.5-2.el7                          epel                       50 k
Installing for dependencies:
 python-backports                                         x86_64                      1.0-8.el7                            base                      5.8 k
 python-backports-ssl_match_hostname                      noarch                      3.4.0.2-4.el7                        base                       12 k
 python-setuptools                                        noarch                      0.9.8-4.el7                          base                      396 k
 python34-libs                                            x86_64                      3.4.5-2.el7                          epel                      6.7 M

Transaction Summary
===========================================================================================================================================================
Install  2 Packages (+4 Dependent packages)

Total download size: 8.7 M
Installed size: 36 M
Is this ok [y/d/N]: y
Downloading packages:
(1/6): python-backports-1.0-8.el7.x86_64.rpm                                                                                        | 5.8 kB  00:00:00
(2/6): python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch.rpm                                                                 |  12 kB  00:00:00
(3/6): python-setuptools-0.9.8-4.el7.noarch.rpm                                                                                     | 396 kB  00:00:00
(4/6): python34-3.4.5-2.el7.x86_64.rpm                                                                                              |  50 kB  00:00:00
(5/6): python34-libs-3.4.5-2.el7.x86_64.rpm                                                                                         | 6.7 MB  00:00:14
(6/6): python-pip-7.1.0-1.el7.noarch.rpm                                                                                            | 1.5 MB  00:00:20
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                      433 kB/s | 8.7 MB  00:00:20
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python-backports-1.0-8.el7.x86_64                                                                                                       1/6
  Installing : python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch                                                                                2/6
  Installing : python-setuptools-0.9.8-4.el7.noarch                                                                                                    3/6
  Installing : python34-libs-3.4.5-2.el7.x86_64                                                                                                        4/6
  Installing : python34-3.4.5-2.el7.x86_64                                                                                                             5/6
  Installing : python-pip-7.1.0-1.el7.noarch                                                                                                           6/6
  Verifying  : python-setuptools-0.9.8-4.el7.noarch                                                                                                    1/6
  Verifying  : python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch                                                                                2/6
  Verifying  : python34-libs-3.4.5-2.el7.x86_64                                                                                                        3/6
  Verifying  : python-backports-1.0-8.el7.x86_64                                                                                                       4/6
  Verifying  : python-pip-7.1.0-1.el7.noarch                                                                                                           5/6
  Verifying  : python34-3.4.5-2.el7.x86_64                                                                                                             6/6

Installed:
  python-pip.noarch 0:7.1.0-1.el7                                               python34.x86_64 0:3.4.5-2.el7

Dependency Installed:
  python-backports.x86_64 0:1.0-8.el7       python-backports-ssl_match_hostname.noarch 0:3.4.0.2-4.el7       python-setuptools.noarch 0:0.9.8-4.el7
  python34-libs.x86_64 0:3.4.5-2.el7

Complete!
[root@cms ~]#

[root@cms ~]# python3 -V
Python 3.4.5
[root@cms ~]#

[root@cms ~]# yum install python34-setuptools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: mirror.pregi.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
Resolving Dependencies
--> Running transaction check
---> Package python34-setuptools.noarch 0:19.2-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================
 Package                                       Arch                             Version                               Repository                      Size
===========================================================================================================================================================
Installing:
 python34-setuptools                           noarch                           19.2-3.el7                            epel                           373 k

Transaction Summary
===========================================================================================================================================================
Install  1 Package

Total download size: 373 k
Installed size: 1.3 M
Is this ok [y/d/N]: y
Downloading packages:
python34-setuptools-19.2-3.el7.noarch.rpm                                                                                           | 373 kB  00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python34-setuptools-19.2-3.el7.noarch                                                                                                   1/1
  Verifying  : python34-setuptools-19.2-3.el7.noarch                                                                                                   1/1

Installed:
  python34-setuptools.noarch 0:19.2-3.el7

Complete!
[root@cms ~]#

[root@cms ~]# easy_install-3.4 pip
Searching for pip
Reading https://pypi.python.org/simple/pip/
Best match: pip 9.0.1
Downloading https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
Processing pip-9.0.1.tar.gz
Writing /tmp/easy_install-v0rj6ku0/pip-9.0.1/setup.cfg
Running pip-9.0.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-v0rj6ku0/pip-9.0.1/egg-dist-tmp-1shmezvq
/usr/lib64/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'python_requires'
  warnings.warn(msg)
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching '.mailmap'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching '.landscape.yml'
warning: no previously-included files found matching 'pip/_vendor/Makefile'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files found matching 'dev-requirements.txt'
warning: no previously-included files found matching 'appveyor.yml'
no previously-included directories found matching '.github'
no previously-included directories found matching '.travis'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'contrib'
no previously-included directories found matching 'tasks'
no previously-included directories found matching 'tests'
creating /usr/lib/python3.4/site-packages/pip-9.0.1-py3.4.egg
Extracting pip-9.0.1-py3.4.egg to /usr/lib/python3.4/site-packages
Adding pip 9.0.1 to easy-install.pth file
Installing pip3 script to /usr/bin
Installing pip script to /usr/bin
Installing pip3.4 script to /usr/bin

Installed /usr/lib/python3.4/site-packages/pip-9.0.1-py3.4.egg
Processing dependencies for pip
Finished processing dependencies for pip
[root@cms ~]#
[root@cms ~]# python3 -V
Python 3.4.5
[root@cms ~]#
[root@cms ~]# pip3 -V
pip 9.0.1 from /usr/lib/python3.4/site-packages/pip-9.0.1-py3.4.egg (python 3.4)
[root@cms ~]#

Successfully, installed Python3 and pip3. Enjoy!!!

5 Comments

  1. Pingback: How to Install django on CentOS 7

  2. Pingback: Setup Django with MySQL on CentOS 7

  3. Krishna Prajapati

    Ubuntu 18.04 lts comes with default python3. Use the below command to install pip3

    # python3 –version
    Python 3.6.7

    # apt-get install python3-pip

    # pip3 –version
    pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

  4. Thank you Krisna!

Leave a Reply

Your email address will not be published. Required fields are marked *