标签:python
1.下载安装python2.7
安装前准备:
yum install zlib-devel openssl-devel -y
注:在编译安装python2.7之前必须先安装zlib-devel包,不然在安装setuptools时会出现以下错误:
AttributeError: ‘NoneType‘ object has no attribute ‘decompressobj‘
下载安装:
wget wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2 tar xf Python-2.7.3.tar.bz2 cd Python-2.7.3 ./configure --prefix=/usr/local/python2.7 make && make install
建立软连接,使系统默认的 python指向 python2.7:
mv /usr/bin/python /usr/bin/python2.6.6 ln -s /usr/local/python2.7/bin/python2.7 /usr/bin/python
解决yum不兼容python2.7问题:
sed -i ‘s#!/usr/bin/python#!/usr/bin/python2.6.6#g‘ /usr/bin/yum
2.安装pip
安装setuptools:
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py python ez_setup.py
下载安装pip:
wget --no-check-certificate tar zxf 1.5.5.tar.gz python setup.py install
注:编译安装python之前必须安装openssl,openssl-devel包,否则会出现以下错误:
[root@localhost pip-1.5.5]# pip list Traceback (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
参考资料:http://my.oschina.net/pangyangyang/blog/191863
标签:python
原文地址:http://wangyongbin.blog.51cto.com/8964308/1705385