centos默认python版本_CentOS6.5默认Python版本升

### CentOS6.5系统自带版本是python2.6.6,升级至python2.7.5操作如下:

# tar zxvf Python-2.7.5.tgz

# cd Python2.7.5

./configure --prefix=/usr/local/python2.7 --enable-unicode=ucs4--enable-shared

# make && make install

# cd /usr/bin/

# ls -l |grep python

# mv python python.back

# ln -sv /usr/local/python2.7/bin/python/usr/bin/python

# cp /usr/local/python2.7/lib/libpython2.7.so.1.0 /usr/local/lib

# cd /usr/local/lib

# ln -s libpython2.7.so.1.0 libpython2.7.so

# whereis libpython2.7.so.1.0

libpython2.7.so.1: /usr/local/lib/libpython2.7.so.1.0   //显示即OK

# vim /etc/ld.so.conf.d/ python2.7.conf

/usr/local/lib      //添加此内容

# ldconfig

# ldconfig -v |grep libpython*     //查看链接库信息

libpython2.7.so.1.0 -> libpython2.7.so.1.0

libpython2.6.so.1.0 -> libpython2.6.so.1.0

# python -V      //测试成功显示如下

Python 2.7.5

### FAQ

(1)报错:django.core.exceptions.ImproperlyConfigured: Error loading MySQLdbmodule: libpython2.7.so.1.0: cannot open shared object file: No such file ordirectory

解决:编译时需要添加:--enable-unicode=ucs4--enable-shared

(2)报错:python: error while loading shared libraries: libpython2.7.so.1.0:cannot open shared object file: No such file or directory

解决:配置可共享的动态链接库

(3)由于默认版本是Python2.6修改成Python2.7以后yum安装软件时会报问题,例如:

here was a problem importing one of thePython modules required to run yum. The error leading to this problem was:

No module named yum ……It's possible that the above module doesn't match the currentversion of Python, which is:

2.7.5

解决:# vim /usr/bin/yum,修改第一行为:#!/usr/bin/python2.6    //即使用系统原来的python2.6版本

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值