Home >Operation and Maintenance >Linux Operation and Maintenance >centos7.1 installation python2.7.10 detailed tutorial
In order to test mesos, I built centos7.1, used minimal installation, and then installed net-tools, the "development tools" set myself. Later, I wanted to install the DCOS Cli tool, but found that python's pip was not available.
After searching, I found that the automatic python version of Centos7 is 2.7.5, without openssl encryption, and the things to be downloaded are https. I searched for a long time, hoping to make pip ignore the https verification, but to no avail. . I found information that versions 2.7.9 and above come with the openssl plug-in. Well, try this!
1. It took two days to install a bunch of required software packages because I was fooled by them. One step at a time!
yum -y install openssl openssl-devel ncurses-devel.x86_64 bzip2-devel sqlite-devel python-devel zlib
2. Download the python2.7.10 source code package and unzip it to a temporary directory. I put it in /tmp
wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz tar zxvf Python-2.7.10.tgz
3. Compile
Before compiling, Note that you need to use "--enable-shared" when configuring, which means generating a dynamic link library. (Otherwise, there will be errors when compiling mod_wsgi later.) Just using this option is not enough. I started using only the --enable-shared option. I found that after the compilation was completed, I entered the Python2.7.10 directory and executed python, python2, and python2.7 in the terminal. Prompt for python2.7.5. Therefore, when executing the configure command, you must also add the "-rpath" option, which indicates whether to install the generated library in the installation directory of the software. The default is in the installation directory, otherwise specify the path yourself.
Create a directory first, otherwise an error will occur when configuring later:
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 a new version
Be sure to keep the original python2.7.5 here, I At first, I directly overwritten the old version, but found that yum could not be used. After a lot of effort, I couldn't fix it, so I had to reinstall the system. It was the virtual machine for testing anyway (but I found a way to fix it 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 the problem of yum
Because yum needs to use the Python2.7.5 version, yum should not be able to work now. You also need to set up the yum-related files so that when executing yum-related commands There will be no mistakes. vi /usr/bin/yum, modify the first sentence and replace it with the reserved version of 2.7.5:
!/usr/bin/python2.7.5
I have read many people saying that I changed it After completing the above, everything was fine. After I modified the above, yum still had problems, and then modified the first sentence under "/usr/libexec/urlgrabber-ext-down" according to the problem:
!/usr/bin/python2.7.5
Sure enough, the familiar yum interface is out!
5. Install setuptools and pip
The old versions of these cannot take effect anymore and have to be reinstalled. I encountered many pitfalls here, my chrysanthemums were broken, and my whole body was injured!
Download the ez_setup.py file and install setuptools:
wget https://bootstrap.pypa.io/ez_setup.py
Run the following command to install. Because the zlib-devel module has not been installed before, the following command failed to execute. There is no way. yum install zlib- devel, and then recompile python.
python ez_setup.py
Download the pip source code and enter the source code directory to install. This step also took a long time because the relevant components in the first step were not installed.
wget https://pypi.python.org/packages/source/p/pip/pip-7.1.2.tar.gz#md5=3823d2343d9f3aaab21cf9c917710196 tar zxvf Python-2.7.10.tgz cd Python-2.7.10 python setup.py install
Added A soft link, this step seems not very necessary:
ln -fs /usr/local/python/2.7.10/bin/pip /usr/bin/pip
I thought that everything would be fine, but when I ran pip, an error was reported directly, because the dependent components were not installed.
Finally, it is best to add the new python path to the PATH environment variable, otherwise other components will not run properly.
The above is the detailed content of centos7.1 installation python2.7.10 detailed tutorial. For more information, please follow other related articles on the PHP Chinese website!