CentOS6.5 upgrade Python to 2.7 and install PIP

Source: Internet
Author: User

1. Download and install python2.7

Preparation before installation:

Yum Install Zlib-devel openssl-devel-y

Note : You must install the Zlib-devel package before compiling the python2.7 installation, or you will receive the following error when installing Setuptools:

Attributeerror: ' Nonetype ' object has no attribute ' decompressobj '

Download the installation:

wget wget Http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2tar XF python-2.7.3.tar.bz2cd python-2.7.3./ Configure--prefix=/usr/local/python2.7make && make install

Establish a soft connection so that the system default Python points to python2.7:

mv/usr/bin/python/usr/bin/python2.6.6 ln-s/usr/local/python2.7/bin/python2.7/usr/bin/python

Troubleshooting Yum incompatibility python2.7 issues:

Sed-i ' S#!/usr/bin/python#!/usr/bin/python2.6.6#g '/usr/bin/yum

2. Install Pip

Install Setuptools:

wget Https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.pypython ez_setup.py

Download install PIP:

wget--no-check-certificate tar zxf 1.5.5.tar.gzpython setup.py Install

Note : The Openssl,openssl-devel package must be installed before compiling and installing Python, otherwise the following error will occur:

[[email protected] pip-1.5.5]# pip listtraceback  (most recent call  Last):  file  "/usr/bin/pip", line 9, in <module>     load_entry_point (' pip==1.5.5 ',  ' console_scripts ',  ' Pip ') ()   File  "build/ bdist.linux-i686/egg/pkg_resources/__init__.py ", line 558, in load_entry_point   file  "build/bdist.linux-i686/egg/pkg_resources/__init__.py",  line 2682, in load_entry _point  file  "build/bdist.linux-i686/egg/pkg_resources/__init__.py", line 2355,  in load  file  "build/bdist.linux-i686/egg/pkg_resources/__init__.py",  line 2361,  in resolve  File  "/usr/local/python2.7/lib/python2.7/site-packages/ pip-1.5.5-py2.7.egg/pip/__init__.py ", line 10, in <module>     From pip.util import get_installed_distributions, get_prog  file  "/usr/local/python2.7/lib/python2.7/site-packages/ pip-1.5.5-py2.7.egg/pip/util.py ",  line 18, in <module>    from  pip._vendor.distlib import version  File  "/usr/local/python2.7/lib/python2.7/ site-packages/pip-1.5.5-py2.7.egg/pip/_vendor/distlib/version.py ",  line 14, in <module >    from .compat import string_types  File  "/usr/local/ Python2.7/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/_vendor/distlib/compat.py ",  line 31,  in <module>    from urllib2 import  (Request, urlopen,  urlerror, httperror,importerror: cannot import name httpshandler

Reference: http://my.oschina.net/pangyangyang/blog/191863

CentOS6.5 upgrade Python to 2.7 and install PIP

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.