想用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 7, in <module>
from pip._internal import main
ImportError: No module named _internal
报这个错误的原因是因为系统装了多个pip版本
# whereis pip
pip: /usr/bin/pip /usr/bin/pip2.6 /usr/local/bin/pip2.7 /usr/local/bin/pip
执行下面的命令可以解决这个问题:
mv /usr/bin/pip /usr/bin/pip_bak
ln -sv /usr/local/bin/pip2.7 /usr/bin/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