CentOS下本来Python是2.4的,好像不支持requests模块.我就升级到python2.7,结果yum又不能用了.下面是完整的解决方案.
Python升级
# yum install gcc gcc-c++.x86_64 compat-gcc-34-c++.x86_64 openssl-devel.x86_64 zlib*.x86_64
# wget http://www.python.org/ftp/python/2.7/Python-2.7.tar.bz2
# tar -xvjf Python-2.7.tar.bz2
# cd Python*
# ./configure –prefix=/opt/python27
# make
# make install
#vi ~/.bash_profile
这时候Python已经升级好了,但是默认的Python版本还是2.4.3
# mv /usr/bin/python /usr/bin/python_backup
# ln -s /opt/python27/bin/python /usr/bin/
# python -V
Python 2.7
这个时候yum又不能用了
# vim /usr/bin/yum
#!/usr/bin/python
改成
#!/usr/bin/python2.4
这时候yum修复了,下面就是安装easy_install,pip和requests
# curl -O http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
# chmod 775 setuptools-0.6c11-py2.7.egg
# sh setuptools-0.6c11-py2.7.egg
# curl -O http://pypi.python.org/packages/source/p/pip/pip-1.0.tar.gz
# tar xvfz pip-1.0.tar.gz
# cd pip-1.0
# python setup.py install
# /opt/python27/bin/easy_install requests
更多CentOS相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14