Centos6.5下升级Python 2.6.6 to python 2.7.3

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

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

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值