This article source: http://blog.csdn.net/pan_tian/article/details/7684409
Download addresses for each version of Python:
https://www.python.org/downloads/source/
The python installation process in Linux environment
http://blog.csdn.net/pan_tian/article/details/7684409 the Python installation process in a Linux Environment
Preface
In general, Linux comes pre-loaded with Python, but this pre-installed Python version is generally very low, many of Python's new features are not, you have to reinstall a new version, from the screenshot below, you can see my Linux, pre-installed Python version is very low, The old version of 2.4.3. Here I am ready to install a slightly more mainstream version of 2.7.3 at this stage.
Download
Website Download Address: http://www.python.org/download/
installation Decompression
What you need to do after that requires you to have super User or administrator privileges. Figure conveniently, I switched directly to the root user.
Tar-xzf python-2.7.3.tgz
After decompression into the Python-2.7.3 directory, you will see the file
(Note: Blue for folder, green and black for file) compiling & installation
Run under the Python-2.7.3 root directory
./configure
Complement: After the Configure command is executed, a Makefile file is generated, which is mainly used by the next make command. Open the Makefile and you'll find that the order of the builds is in place, and Linux needs to build the program components in the order that Makefile specifies. |
Make
Make actually compiles your source code and generates the execution file. |
To execute the make install command again
Make Install
Make install actually copies the generated execution files to the necessary directories in the Linux system, such as copying to the/usr/local/bin directory so that all user can run the program. |
Here Python is even installed to complete. Need to say, in fact, other Linux software installation is similar, basic need to walk Configure>make>make install such a process.
Hello World
After the installation, we execute the python command, and you will find that the default Python command still points to the old version 2.4.3
[admin@bej301441 bin]$ which Python
/usr/local/bin/python
Executing the which Python command, you will find that the default Python is in the/usr/local/bin/python directory, and actually our newly installed Python is also in this directory.
Enter python2.7 at the command line, and this will be done to our new Python version.
Create a hello.py file on Linux, with only one line of code written inside
Print "Hello Ptian"
Then run python2.7 hello.py
Enjoy ... I have to admit, when I first saw Python, I was moved by the efficiency of Python, and I never had a programming language that made me feel that programming could be so enjoyable ...
=======eof========
Reprint please indicate the source: http://blog.csdn.net/pan_tian/article/details/7684409