python2.6 升级到 python2.7

  1. 云栖社区>
  2. 博客>
  3. 正文

python2.6 升级到 python2.7

科技小能手 2017-11-12 03:02:00 浏览688
展开阅读全文

想用redis-py-cluster连接redis cluter,查看文档发现只支持python2.7和3的版本,而系统自带的是2.6的版本,需要对系统python版本进行升级。


查看python的版本

# python -V

Python 2.6.6

1.下载Python-2.7.3

# wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz

2.解压

# tar -xvf Python-2.7.13.tgz 

3.更改工作目录

# cd Python-2.7.13

4.安装

# ./configure

# make && make install


5.建立软连接,使系统默认的 python指向 python2.7

# mv /usr/bin/python /usr/bin/python2.6.6

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


6.重新检验Python 版本

# python -V

Python 2.7.13


7.解决升级后yum不可用的问题

# vim /usr/bin/yum

将文件头部的#!/usr/bin/python改成#!/usr/bin/python2.6.6


8.配置iBus

将/usr/bin/ibus-setup 和 /usr/libexec/ibus-ui-gtk  这两个文件中exec python改为exec python2.6


9,安装setuptools

wget https://pypi.python.org/packages/6b/dd/a7de8caeeffab76bacf56972b3f090c12e0ae6932245abbce706690a6436/setuptools-28.3.0.tar.gz#md5=a46750b6bd90a1343466bd57b0e2721a

tar zxvf setuptools-28.3.0.tar.gz 

cd setuptools-28.3.0

python setup.py install


10,安装pip

wget https://pypi.python.org/packages/e7/a8/7556133689add8d1a54c0b14aeff0acb03c64707ce100ecd53934da1aa13/pip-8.1.2.tar.gz#md5=87083c0b9867963b29f7aba3613e8f4

tar zxvf  pip-8.1.2.tar.gz 

cd pip-8.1.2 

python setup.py install


11,测试pip是否可用

pip install mysql-python

Traceback (most recent call last):

  File "/usr/bin/pip", line 5, in <module>

    from pkg_resources import load_entry_point

  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2991, in <module>

  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2977, in _call_aside

  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3004, in _initialize_master_working_set

  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 664, in _build_master

  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 677, in _build_from_requirements

  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 856, in resolve

pkg_resources.DistributionNotFound: The 'pip==7.1.0' distribution was not found and is required by the application

出现上面报错时的处理方法:

    mv /usr/bin/pip /usr/bin/pip0

    cp /usr/bin/pip2.7 /usr/bin/pip



本文转自 emma_cql 51CTO博客,原文链接:http://blog.51cto.com/chenql/1948444

网友评论

登录后评论
0/500
评论
科技小能手
+ 关注