您的位置:首页 > 运维架构 > Linux

Centos 5.5 python 2.4升级python 2.6.6

2013-05-24 21:40 507 查看
Centos 5.5默认没有安装sqlite-devel,所以要先安装sqlite-devel,在编译升级python,才可以使用sqlite3。
1.先安装sqlite-devel:

[root@localhost ~]#yum install sqlite-devel -y
2.下载编译安装python2.6.6
[root@localhost ~]#wget -c http://www.python.org/ftp/python/2.6.6/Python-2.6.6.tar.bz2 [root@localhost ~]#tar jxvf Python-2.6.6.tar.bz2
[root@localhost ~]#cd Python-2.6.6
[root@localhost Python-2.6.6]#./configure --with-threads --enable-shared //默认安装路径:/usr/local/lib/
[root@localhost Python-2.6.6]#make && make install
3.修改系统默认版本

[root@localhost Python-2.6.6]#mv /usr/bin/python /usr/bin/python.bak
[root@localhost Python-2.6.6]#ln -s /usr/local/bin/python2.6 /usr/bin/python
[root@localhost Python-2.6.6]#python -V
Python 2.6.6
4.解决系统python软链接指向python2.6版本后,yum不能正常工作
[root@localhost Python-2.6.6]#vim /usr/bin/yum
#!/usr/bin/python
修改为#!/usr/bin/python2.4
5.如果需要在次编译报错的解决办法
报错信息:python: error while loading shared libraries: libpython2.6.so.1.0: cannot open shared object file: No such file or directory
解决办法:
[root@localhost ~]# vim /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/lib ===》需要添加
[root@localhost ~]# ldconfig
[root@localhost ~]# python -V
Python 2.6.6

本文出自 “斯图尔特” 博客,请务必保留此出处http://stuart.blog.51cto.com/728677/1209419
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: