由于python2.6不在提供支持,所以升级2.7
1、下载python
wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
2、解压:
tar -jxvf Python-2.7.3.tar.bz2
3、进入目录编译
./configure
此时系统报错:
安装gcc解决:
yum -y install gcc gcc-c++ kernel-devel
此时在进行编译,可成功
4、执行如下命令进行安全
make all
make install
make clean
make distclean
5、查看版本
/usr/local/bin/python2.7 -V
6、建立软连接
删除之前链接:mv /usr/bin/python /usr/bin/python2.6
新建软连接: ln -fs /usr/local/bin/python2.7 /usr/bin/python
安装完后,发现yum不能用了,修改usr/bin/yum文件
将
#!/usr/bin/python修改为如下形式即可
安装pip提示报错,提示zipimport.ZipImportError: can't decompress data; zlib not available
先安装setuptools-
uzip解压,python setup.py install 安装
下载pip
解压,python setup.py install 安装
此时不出意外是可以的,但是可能会出现如下错误
ImportError: cannot import name main
解决:
pip文件在usr/bin目录下,cd进去,进行以下修改
from pip import main
if __name__ == '__main__':
sys.exit(main())
修改如下:
from pip import __main__
if __name__ == '__main__':
sys.exit(__main__._main())
ok,上述问题可解决,运行后运气好就没问题了,运气不好,就可能出现ssl问题,错误如下
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
这说明ssl版本太低,所以需要在升级ssl