Question: I am trying to install a Python app that requires python3 on CentOS system. However, my CentOS only has python 2.X installed, but not python 3.X. How can I install python3 on CentOS?
- Python runs on many operating systems such as MS-Windows, Mac OS, Mac OS X, Linux, FreeBSD, OpenBSD, Solaris, AIX, and many varieties of free UNIX like systems. The easiest way to install the Python is to use package manger such as apt-get, yum, a.
- Let’s see how to install Python on each Linux distribution, individually. Install Python on Linux: To install any package on Linux, you need to use specific command based on the package manager. APT package manager – Debian / Ubuntu| Linux Mint Linux User. Ubuntu and Linux Mint distributions use APT for package management. To install Python in these Linux distribution, Open terminal and run command those are given below.
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. If you’re using Python 2.7.9 (or greater) or Python 3.4 (or greater), then PIP comes installed with Python by default. If you’re using an older version of Python, you’ll need to use the installation steps below. Python is an open-source and beginner-friendly programming language. Ubuntu 16.04 and Ubuntu 16.10 come with two versions of Python, Python 2.7 and Python 3.5. At the time of this writing, the latest stable version of Python is 3.6, released on December 23rd, 2016.
As of the latest CentOS 7, the default Python version still remains python 2.7, and python3 is not available in base repositories. If you need to use python3 as part of Python application dependency, there are several ways to install python3 on CentOS.
Method One: Build and Install Python3 from the Source
You can always build python3 from its source manually. Since you can choose the version of python3 to install, this is the surest way to meet Python dependency requirement.
Here is how you can build and install python3 from the source.
First, install minimum necessary tools: Amidianborn book of silence armors.
Then using yum-builddep, set up a necessary build environment for python3 and install missing dependencies. The following command will automatically take care of that.
$ sudo yum-builddep python
Now download the latest python3 (e.g., python 3.5) from https://www.python.org/ftp/python/
$ curl -O https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz
Finally, build and install python3 as follows. The default installation directory is /usr/local. If you want to change this to some other directory, pass '--prefix=/alternative/path' parameter to configure before running make.
$ tar xf Python-3.5.0.tgz
$ cd Python-3.5.0
$ ./configure
$ make
$ sudo make install
$ cd Python-3.5.0
$ ./configure
$ make
$ sudo make install
This will install python3, pip3, setuptools as well as python3 libraries on your CentOS system.
If you want to use python3 as your default Python interpreter, you can define the following alias in your .bashrc. Dress designing software free download.
Method Two: Install Python3 from EPEL Repository
The latest EPEL 7 repository offers python3 (python 3.4 to be exact). Thus if you are using CentOS 7 or later, you can easily install python3 by enabling EPEL repository as follows.
$ sudo yum install epel-release
Then install python 3.4 and its libraries using yum:
Note that this will not install matching pip. To install pip and setuptools, you need to install them separately as follows.
$ curl -O https://bootstrap.pypa.io/get-pip.py
$ sudo /usr/bin/python3.4 get-pip.py
$ sudo /usr/bin/python3.4 get-pip.py
Method Three: Install Python3 from Software Collections (SCL)
Another way to install python3 is via enabling Software Collections (SCL) repository. The SCL repository is available for CentOS 6.5 or later, and the latest SCL offers python 3.3. Once you enable the SCL repository, go ahead and install python3 as follows.
To use python3 from the SCL, you need to enable python3 on a per-command basis as follows.
$ scl enable python33 <command>
You can also invoke a bash shell with python3 enabled as the default Python interpreter:
Download this article as ad-free PDF (made possible by your kind donation):
Subscribe to Ask Xmodulo
Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.
Support Xmodulo
Install Python 3 Linux Mint
Did you find this tutorial helpful? Then please be generous and support Xmodulo!