Centos7.1 install python2.7.10
To test mesos, we developed centos7.1, installed with minimal installation, and installed net-tools and "development tools. Later, I wanted to install the DCOS Cli tool and found that python pip is unavailable.
After searching, I found that the python version of Centos7 is 2.7.5, without openssl encryption, and all the items to be downloaded are https. After searching for a long time, I hope pip can ignore https verification. Find a message saying that openssl plug-in is provided in version 2.7.9 and later. Okay. Try this!
1. Install a bunch of required software packages for two days!
Yum-y install openssl openssl-develncurses-devel.x86_64 bzip2-develsqlite-develpython-develzlib
2. Download The python2.7.10 source code package and decompress it to a temporary directory. I will put it under/tmp.
Wgethttps: // www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
Tar zxvf Python-2.7.10.tgz
3. Compile
Before compilation, note that "-- enable-shared" should be used in configure to generate a dynamic link library. (Otherwise, an error occurs when mod_wsgi is compiled later.) It is not enough to use only the -- enable-shared option. After compilation is completed, enter the Python2.7.10 directory, execute python, python2, and python2.7 on the terminal and return the python2.7.5 prompt. Therefore, when executing the configure command, you must add the "-rpath" option, which indicates whether to install the generated library in the installation directory of the software. The default value is in the installation directory, otherwise, specify the path.
Create a directory first, otherwise there will be an error in subsequent configure:
Mkdir-p/usr/local/python/2.7.10/lib
./Configure -- enable-shared -- prefix =/usr/local/python/2.7.10 LDFLAGS = "-Wl,-rpath/usr/local/python/2.7.10/lib"
Make & make install & make clean
4. Switch to the new version
The original python2.7.5 must be retained here. I started to directly overwrite the old version. I found that yum was useless, and I had to reload the system because I had to pay a lot of effort and didn't fix it, it is a tested Virtual Machine (but the solution was found the next day)
Mv/usr/bin/python/usr/bin/python2.7.5
Ln-fs/usr/local/python/2.7.10/bin/python2.7/usr/bin/python
5. Solve yum Problems
Because yum needs to use Python2.7.5, yum cannot work now, and you need to set yum-related files so that no errors will occur when you execute yum-related commands. Vi/usr/bin/yum, modify the first sentence and replace it with the reserved version 2.7.5:
! /Usr/bin/python2.7.5
After reading this, many people said that everything would be fine after the above change. After I modified the above, yum still had a problem, then, modify the first sentence in "/usr/libexec/urlgrabber-ext-down" based on the problem:
! /Usr/bin/python2.7.5
The familiar yum interface came out!
5. Install setuptools and pip
Old versions of these cannot take effect. I have to reinstall them. I have encountered many pitfalls here, and my chrysanthemums are completely damaged!
Download the ez_setup.py file and install setuptools:
Wgethttps: // bootstrap. pypa. io/ez_setup.py
Run the following command to install zlib-devel, because the zlib-devel module has not been installed before. The following command cannot be executed successfully. No way, run yum install zlib-devel and compile python.
Python ez_setup.py
Download the pip source code and go to the source code directory for installation. This step is also because the components in the first step are not installed, and it has been stuck for a long time.
Wgethttps: // response
Tar zxvfPython-2.7.10.tgz
CdPython-2.7.10
Python setup. py install
Adding a soft link does not seem necessary:
Ln-fs/usr/local/python/2.7.10/bin/pip/usr/bin/pip
I thought everything would be fine. I ran pip and reported an error directly because the dependent components were not installed.
Finally, we recommend that you add the new python path to the path environment variable. Otherwise, other components may not run properly.