1、升级安装Python2.7
解压tar.xz文件:先 xz -d xxx.tar.xz 将 xxx.tar.xz解压成 xxx.tar 然后,再用 tar xvf xxx.tar来解包
wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tar.xz
xz -d Python-2.7.15.tar.xz
tar xvf Python-2.7.15.tar.xz
./configure
make
make install
make clean
make distclean
2、修改
mv /usr/bin/python /usr/bin/python2.6.6
ln -s /usr/local/bin/python2.7 /usr/bin/python
vim /usr/bin/yum
#!/usr/bin/python2.6
完成后进行验证:
yum
python -V
3、pip安装
3.1 首先安装setuptools软件包:
(1)下载setuptools包
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz
(2)解压setuptools包
tar zxvf setuptools-2.0.tar.gz
cd setuptools-2.0
(3)编译setuptools
python setup.py build
(4)开始执行setuptools安装
python setup.py install
3.2 安装pip工具
(1)下载PIP安装包
https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
(2)解压pip安装包:
tar -xzvf pip-9.0.1.tar.gz
cd pip-9.0.1
python setup.py install
如果服务器中没有安装setuptools软件包,则会提示以下错误:
提示错误:
Traceback (most recent calllast):
File "setup.py", line 5, in <module>
from setuptools import setup, find_packages
ImportError: Nomodule named setuptools
cd pip-9.0.1/
python setup.py install
安装好pip之后,我们就可以直接使用pip安装其他第三方模块包了:
pip install requests
若安装后pip命令无法使用,搜索系统中pip文件,创建命令链接
ln -s /usr/local/python27/bin/pip /usr/bin/pip