CentOS6.5默認Python版本升級到python2.7.5

### CentOS6.5系統自帶版本是python2.6.6,升級至python2.7.5操做以下:python

# wget https://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz  //沒法下載時自行官網下載django

# tar zxvf Python-2.7.5.tgzvim

# cd Python2.7.5python2.7

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

# make && make install測試

# cd /usr/bin/ui

# ls -l |grep pythonthis

# mv python python.backspa

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

# 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版本

相關文章
相關標籤/搜索