Linux upgrade python2.7, install Pip,setuptools,zlib

Source: Internet
Author: User
Tags install openssl

1, python2.7 and Pip in 192.168.0.65

#ssh 192.168.0.65

    • Upgrade to python2.7

#cd/usr/local

#wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz     

# tar ZXVF python-2.7.10.tgz

# CD Python-2.7.10

# mkdir/usr/local/python2.7

#./configure--prefix=/usr/local/python2.7

#make && make Install

#which python

# Mv/usr/bin/python/usr/bin/python_old

# ln-s/usr/local/python2.7/bin/python2.7/usr/bin/python

Reference Documents http://www.cnblogs.com/lanxuezaipiao/archive/2012/10/21/2732864.html

You need to install Zlib,setuptools before installing PIP

    • Installing zlib

#yum-y install zlib error, as follows:

No module named Yum

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang /zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

The reason for this error is that I upgraded Python, which makes Yum unusable.

Reference Documentation: http://blog.csdn.net/ei__nino/article/details/8495295

Workaround:

# Vi/usr/bin/yum

#!/usr/bin/python_old

//The first line of the file changed to #!/usr/bin/python_old because I renamed the old Python python_old. and Yum matches the old Python.

#/sbin/service yum-updatesd Restart

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

# yum-y Install zlib zlib-devel //Installation Successful! But installation Setuptools still error. Need to recompile python.

Reference Documents http://www.idjango.com/content/0/

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

Recompile python below

# cd/usr/local/python-2.7.10

#./configure--prefix=/usr/local/python2.7

#make && make Install




    • Installing Setuptools

#cd/usr/local

# Curl-o Https://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz

# tar ZXVF setuptools-2.0.tar.gz

# CD setuptools-2.0

#python setup.py Build

#python setup.py Install//Success


    • Install PIP

PIP official website Https://pypi.python.org/pypi/pip

#cd/usr/local

# Curl-o https://pypi.python.org/packages/source/p/pip/pip-7.1.2.tar.gz#md5=3823d2343d9f3aaab21cf9c917

# Curl-o https://pypi.python.org/packages/source/p/pip/pip-7.1.2.tar.gz

Use wget download will error, here instead of Curl-o can, these 2 commands download the package is right

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang /zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
# tar ZXVF pip-7.1.2.tar.gz
# CD pip-7.1.2
#python setup.py Install

# ln-s/usr/local/python2.7/bin/pip/usr/bin/pip

The //pip is installed by default under/usr/local/python2.7/bin/

#pip // test PIP

Error: Importerror:cannot Import name Httpshandler

The reason is that openssl,openssl-devel two packages are not installed correctly

Workaround:

#Yum install OpenSSL openssl-devel-y

Continue to error, then I recompile Python and Pip. OK no longer has an error.



Linux upgrade python2.7, installing Pip,setuptools,zlib

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.