centos5.x默认安装的python为2.4版本,但是部分软件需要2.5以上的python.
所以我们需要升级Python,比如到2.7版本,步骤
curl -O http://python.org/ftp/python/2.7/Python-2.7.tgz
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运行可能会遇到错误,如下:
所以pip也需要升级到配套的版本:
curl -O http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
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即可。
所以我们需要升级Python,比如到2.7版本,步骤
curl -O http://python.org/ftp/python/2.7/Python-2.7.tgz
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运行可能会遇到错误,如下:
[root@dev1 bin]# pipTraceback (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_packagesImportError: cannot import name walk_packages
所以pip也需要升级到配套的版本:
curl -O http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
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即可。
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow