Centos7.1 install python2.7.10

Source: Internet
Author: User
To test mesos, we developed centos7.1 and installed net-tools, & ldquo; Development Tool & rdquo. Later, I wanted to install the DCOSCli tool and found that python pip is unavailable. After searching, we found that the python version of Centos7 is 2.7.5 without openssl encryption.

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-devel ncurses-devel.x86_64 bzip2-devel sqlite-devel python-devel zlib

2. download the python2.7.10 source code package and decompress it to a temporary directory. I will put it under/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 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:

Wget https://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.

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

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.