Home » Python » Python installation under Linux

Python installation under Linux


in general, the pre installed versions of Linux are relatively low, and we may need to use some of the features of the new version of Python at hand, so we may need to install a new version of Python at this time,.

I'm going to take the current popular version of 2.7.11, for example,.

Download the new version

new version of Python can be obtained from Python, official website, ,

Find the version you want to install and download.

in the Python>>> Downloads>>> Source code

copies the downloaded installation package to the directory you want to unzip and extracts:

Tar -zxvf Python-2.7.11.tgz

Go to the Python2.7.11 root directory:

CD Python-2.7.11

Execute the configure file:


Compile source code:



Sudo make install

To configure

when the above steps are executed, we issue the "Python" command to find that the old version is running or not. What's the problem?
In fact, we just before the installation will generate the executable file is copied to the /usr/local/bin directory, we carry out "Python" command is used inside the /usr/bin executable file (of course, it also depends on your environment variable configuration). So we need to convert the python command with our newly installed binary executable file in /usr/bin associated. There will be python python version and python-config commands with a new installation, first use

RM, -rf, python, and RM -rf python-config

Then use

LN, -s, /usr/local/bin/python, python,

And LN, -s, /usr/local/bin/python-config, python-config,

Create a new link.

If you want two versions exist at the same time so that you can not delete before the link has been built, and a new link named other names, such as python2.7 and python2.7-config. at this time if you need to start a new version of the python words in the input terminal python2.7 start. Of course you can not build a link to /usr/local/bin directly below start a new version of python.