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