The original address is http://blog.csdn.net/u012538536/article/details/47360929.
CentOS6.5 is the original python, my image inside the Python version is 2.6.6. If you want to update a newer version of Python yourself, you can do this:
Install the python2.7 installation package.
Download the python2.7.13 installation package from the official website.
https://www.python.org/download/releases/2.7.13.
After decompression, do the following steps:
(1)./configure--prefix=/usr/local/pyton2.7 (fill in your installation directory, the default is this directory).
(2) Perform the make command to compile the source code.
(3) Do install with make install.
(4) Do clean clear the temporary compilation files generated during installation
If you do not have an error, it means that python2.7 has been installed on your server.
Entering the python command at the terminal will reveal that the original version of the system is 2.6 and does not use our 2.7 version.
This is where you can use the which Python command to view the Python command that was called in that location, typically in/usr/bin/python here. But here python points to the system that comes with the 2.6 version. And we installed the python2.7 command in/usr/local/bin/python (the front path is determined according to your installation path) here. We can back up the/usr/bin/python to another name: Cp/usr/bin/python/usr/bin/python. Then make a soft connection ln-s/usr/local/bin/python/usr/bin/python. This time we once again in the terminal Input Python command has become version 2.7.
When you enter Yum install XXXX, you will be prompted that the Yum module cannot be found.
In fact, Yum relies on the original python. When we modified the original Python version, this yum would call our 2.7 version of Python, and we would have an error without yum on the 2.7 version. We only need to use which Yum to find the address of Yum, then edit the Yum file and then change the #!/usr/bin/python of the first line of the file to #!/usr/bin/python2.6 (in fact/usr/ There is still python2.6 this file underneath the bin). This way, yum can be used again.
########## #我靠, this guy is almost identical to what I wrote in my notes ... Think わず copied the ###########.
Installing Pip and Setuptools
(based on experience a new system often does not zlib-devel,openssl-devel these packages, make sure that Zlib,zlib-devel,openssl, Openssl-devel four packages are in order to ensure a smooth installation of Setuptools and PIP)
Originally did not want to engage in setuptools, but rare record, just take this opportunity to figure out the relationship between the two things. Setuptools is a Python-based management tool that allows you to install, upgrade, uninstall, and so on for Python's third-party packages. When our python does not have a third-party tool installed, we can install Setuptools through the source package. Please note that this source code package is not C source code but Python source code, that is, the installation routine is not./configure make the set, but the Python setup.py build and install the set. (The process of installing setuptools may encounter a lot of problems that depend on the package that does not exist: The most stupid way, on https://pypi.python.org/pypi one search by Python setup.py build and then install the routines installed)
Linux will have a easy_install command in path after the installation is complete, and Windows will appear in the Scripts folder in the root directory of Python Easy_ Install.exe files (These are my own perceptions, there must be more accurate descriptions just I don't know.) )。 Running these two executable programs allows you to install some of the things Python needs. For example, we can use Easy_install to install PIP. In addition, the installation process on Linux may encounter no zlib package errors (according to the original blog post description), in fact, is required to have a Linux zlib and zlib-devel two packages, see which one less rpm to see. You will need to recompile and install Python Once the installation is complete.
Pip is very similar to setuptools (as it seems) and is also a handy Python module management tool. In addition to the above mentioned by the Setuptools to install outside, of course, can also be installed with the source code. Routines and Setuptools are basically the same, but Pip source installation is also required setuptools support, so still must first install Setuptools. PIP installation may not be able to install the Python module through PIP installed, if the error is related to Https,ssl, it may be because the Linux system does not install Openssl-devel package, like Zlib-devel, After installing with Yum, recompile the installation under Python and then reinstall the PIP. The PIP should now be ready to install the Python module.
"Linux" CentOS6.5 install Python2.7 and PIP tools