The python version 3 is not available from CentOS 7 repositories. The following config will show you how to compile and install Python version 3 from source on CentOS 7 Linux. Let's start by installation of some required tools which you will need for this tutorial.
# yum install yum-utils make wget
Next, we will install all python build prerequisites to meet all compilation requirements:
# yum-builddep python
Following steps can be executed as a regular user. First, download your desired python version from Example:
$ wget
At this stage we need to decompress the downloaded tarball:
$ tar xzf Python-3.4.3.tgz
now we are ready for the actual python source code compilation:
$ cd Python-3.4.3
$ ./configure
$ make
Depending on your system, the compilation will take few minutes. If no output errors were produced during the compilation you are ready to install your newly compiled python binaries. The default installation path is /usr/local/bin. Change to root or use sudo command to start installation:
# make install
After installation you can find your new python interpreter at the following location /usr/local/bin/. However, since the python2.7 is a default system wide python interpreter you now need to explicitly set you new version. To change python version only for a single user edit ~/.bashrc file and add a following alias replacing the version number where appropriate:
alias python='/usr/local/bin/python3.4'
Source ~/.bashrc file apply changes:
$ . .bashrc
You now should be all set to use your newly compiled python version:
$ python
Python 3.4.3 (default, Jul 10 2015, 09:30:04)
Submit your RESUME, create a JOB ALERT.
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
Get extra help by visiting our LINUX FORUM or simply use comments below.