Heim  >  Artikel  >  Backend-Entwicklung  >  Centos5.x下升级python到python2.7版本教程

Centos5.x下升级python到python2.7版本教程

WBOY
WBOYOriginal
2016-06-10 15:17:551217Durchsuche

首先到官网下载python2.7.3版本,编译安装

复制代码 代码如下:

$wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
$tar zxvf Python-2.7.3.tgz
$cd Python-2.7.3
$./configure
$make && make install

然后备份原来的python,并把python2.7做软连接到新的位置
复制代码 代码如下:

$mv /usr/bin/python /usr/bin/python.bak
$ln -s /usr/local/bin/python2.7 /usr/bin/python
$python -V

版本提示为2.7.3
更改yum,使其能正常运行
复制代码 代码如下:

$vim vim /usr/bin/yum

把#/usr/bin/python改成#/usr/bin/python2.4 这样yum可以正常运行了

安装easy_install

复制代码 代码如下:

$yum install python-setuptools

然后安装python-setuptools 到pypi网站下载python-setuptools,版本要和yum的时候版本一致,不然运行的时候会出现:
复制代码 代码如下:

$ easy_install rsa
Traceback (most recent call last):
  File "/usr/bin/easy_install", line 5, in
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

然后:
复制代码 代码如下:

$wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c5.tar.gz
$tar zxvf setuptools-0.6c5.tar.gz
$cd setuptools-0.6c5
$python setup.py install

安装成功 这样就可以方便的使用easy_install来安装python的库了
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn