centos5.x默认安装的python为2.4版本,但是部分软件需要2.5以上的python.
所以我们需要升级Python,比如到2.7版本,步骤
curl -O
tar xfz Python-2.7.tgz
cd Python-2.7
./configure
make && make install
把/usr/bin/python更换为python2.7的软链接
ln -s /usr/local/bin/python2.7.3 /usr/bin/python
用python -V确认一下版本。
但问题是把python升级后,原先安装的pip运行可能会遇到错误,如下:
[plain] view plain copy
[root@dev1 bin]# pip
Traceback (most recent call last):
File "/usr/bin/pip", line 7, in ?
sys.exit(
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 236, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 2097, in load_entry_point
return ep.load()
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 1830, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.4/site-packages/pip-1.2.1-py2.4.egg/pip/__init__.py", line 9, in ?
from pip.basecommand import command_dict, load_command, load_all_commands, command_names
File "/usr/lib/python2.4/site-packages/pip-1.2.1-py2.4.egg/pip/basecommand.py", line 4, in ?
from pkgutil import walk_packages
ImportError: cannot import name walk_packages
所以pip也需要升级到配套的版本:
curl -O
sh setuptools-0.6c11-py2.7.egg
easy_install pip
现在再查看/usr/local/bin目录下面的pip:
[root@dev1 bin]# ll /usr/local/bin |grep pip
-rwxr-xr-x 1 root root 250 Oct 18 17:23 pip
-rwxr-xr-x 1 root root 258 Oct 18 17:23 pip-2.7
用pip-2.7即可。
温馨提示:答案为网友推荐,仅供参考