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
# 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
# chmod 775 setuptools-0.6c11-py2.7.egg
# sh setuptools-0.6c11-py2.7.egg
# curl -O
# tar xvfz pip-1.0.tar.gz
# cd pip-1.0
# python setup.py install
# /opt/python27/bin/easy_install requests