CentOS Python2.4升级到Python2.7

本网站用的阿里云ECS,推荐大家用。自己搞个学习研究也不错
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

未经允许不得转载:演道网 » CentOS Python2.4升级到Python2.7

赞 (0)
分享到:更多 ()

评论 0

评论前必须登录!

登陆 注册