SUSE Linux下升级Python2.4到2.6

原来的版本为2.4,因在安装scons会报关于Python的模块问题

所以就在SUSE Linux下进行升级到2.6

SUSE Linux下升级Python2.4到2.6

若想要使用rpm -e命令删除python的话是无法删除的,因为软件的依赖性。

所以使用源代码包进行安装升级


下载2.6.8的版本

创建安装目录  mkdir /usr/local/python2.6

进行编译安装  ./configure --prefix=/usr/local/python2.6  make&make install

创建连接

mv /usr/bin/python /usr/bin/python_bak (保存原来的版本)

ln -s /usr/local/python2.6/bin/python /usr/bin

测试结果

SUSE Linux下升级Python2.4到2.6

万事没有那么顺风顺水。。。

报错了。。。

ImportError: No module named readline


谷歌之~貌似缺少readline模块


2 安装 readline

装 readline 之前,需要先安装 setuptools

cd /usr/src/

wget #md5=7df2a529a074f613b509fb44feefe74e

tar zxvf setuptools-0.6c11.tar.gz

cd setuptools-0.6c11/

python setup.py install


出现"

Installed /usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg

Processing dependencies for setuptools==0.6c11

Finished processing dependencies for setuptools==0.6c11

"      表示安装成功


然后,安装 readline-devel ,从SuSe系统自带的DVD光盘拷贝对应rpm包.

rpm -ivh readline-devel-5.1-24.13.x86_64.rpm

rpm -ivh readline-devel-32bit-5.1-24.13.x86_64.rpm

装完这两个依赖包,就可以开始安装 readline 了

cd /usr/src/

wget ftp://ftp.cwru.edu/pub/bash/readline-5.2.tar.gz

tar zxvf readline-5.2.tar.gz

cd readline-5.2/

CFLAGS="-O3 -fPIC" ./configure

(一定要加"-O3 -fPIC",不然会报错:"libreadline.a: could not read symbols: Bad value")

make CFLAGS=-fPIC

make CFLAGS=-fPIC install


3. 安装 python 的 readline 模块

cd /usr/src/

wget

tar zxvf readline-2.5.1.tar.gz

cd /usr/src/readline-2.5.1

cp /usr/local/lib/{libreadline.a,libhistory.a} readline/

python setup.py install


出现"

Installed /usr/local/lib/python2.7/site-packages/readline-2.5.1-py2.7-linux-x86_64.egg

Processing dependencies for readline==2.5.1

Finished processing dependencies for readline==2.5.1

"      表示安装成功


然后再敲python就不会出现"ImportError: No module named readline"的提示了


[root@10.204.140.127 readline-2.5.1]# python

Python 2.7 (r27:82500, Sep 12 2012, 19:00:00)

[GCC 4.1.2 20070115 (prerelease) (SUSE Linux)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/19599.html