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

Centos6.5下升级Python 2.6.6 to python 2.7.3

2013-12-07 10:46 387 查看


Centos6.5下升级Python 2.6.6 to python 2.7.3

对于一个不会使用Pyhthon的我来说,Python的版本实在与我得关系不大,只是以前一直用SSH突然想换到GoAgent,突然发觉自己得Python版本过低就将其升级了下。

以下为升级记录

1.下载Python-2.7.3
wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2[/code] 
2.解压Python-2.7.3
tar -jxvf Python-2.7.3.tar.bz2


3.安装Python-2.7.3

此时应该也是顺利进行,但是到最后却提示“ImportError: No module named _ssl”。

原来默认是安装ssl的。

3.1 首先要先安装openssl包
yum install openssl-devel -y


3.2 开启ssl
vim /usr/software/Python-2.7.5/Modules/Setup.dist


找到SSL相关部分去掉注释就行
#修改结果如下:
# Socket module helper for socket(2)
_socket socketmodule.c timemodule.c

# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
#SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto


3.3 安装Python
./configure
make all
make install
make clean
make distclean


3.4 查看刚刚安装得Python版本
/usr/local/bin/python2.7 -V


3.5 但是使用python -V查看得时候还是2.6.6,此时我们需要将系统默认的python指向到2.7版本。
mv /usr/bin/python /usr/bin/python2.6.6
ln -s /usr/local/bin/python2.7 /usr/bin/python


然后通过python -V查看就会显示为2.7.3了。

4 .解决系统python软链接指向python2.7版本后,yum不能正常工作
vim /usr/bin/yum


将文件头部的

#!/usr/bin/python

改成

#!/usr/bin/python2.6.6

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: