enos6.5升级Python2.6到2.7
1.下载源码包
wgethttps://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz
2.进行解压,准备编译安装
tarzxvfPython-2.7.12.tgzcdPython-2.7.12 ./configure--prefix=/usr/local/python27&&make&&makeinstall&&echo$? 如果以上输出为0,说明没有报错,安装正常
3.添加环境变量
移除以前的版本 mv/usr/bin/python/usr/bin/python26 创建软连接 ln-s/usr/local/python27/bin/python/usr/bin/python 查看版本是否升级成功 python-V Python2.7.12
4.修改yum
如果不修改此项,会导致yum无法使用 vim/usr/bin/yum 修改第一行即可,将环境变量指向以前的python版本#!/usr/bin/python26
5.安装pip(升级完python版本之后,之前yum安装的pip无法使用)
1.安装pip之前首先需要安装setuptools 下载链接https://pypi.python.org/pypi/setuptools下载地址 wgethttps://pypi.python.org/packages/ff/d4/209f4939c49e31f5524fa0027bf1c8ec3107abaf7c61fdaad704a648c281/setuptools-21.0.0.tar.gz#md5=81964fdb89534118707742e6d1a1ddb4--no-check-certificate解压 tarzxvfsetuptools-21.0.0.tar.gz 安装 cdsetuptools-21.0.0pythonsetup.pyinstall2.安装pip 下载链接https://pypi.python.org/pypi/pip下载地址 wgethttps://pypi.python.org/packages/41/27/9a8d24e1b55bd8c85e4d022da2922cb206f183e2d18fee4e320c9547e751/pip-8.1.1.tar.gz#md5=6b86f11841e89c8241d689956ba99ed7--no-check-certificate解压 tarzxvfpip-8.1.1.tar.gz 安装 cdpip-8.1.1pythonsetup.pyinstall3.添加环境变量 安装完之后,之后执行pip还是调用的以前的环境变量,需要手动添加环境变量 mv/usr/bin/pip/usr/bin/pip26 ln-s/usr/local/python27/bin/pip/usr/bin/再次查看版本 pip-V pip8.1.1from/usr/local/python27/lib/python2.7/site-packages/pip-8.1.1-py2.7.egg(python2.7)
6.使用pip安装第三方库
pipinstallpsutil pipinstallMysqLdb-python pipinstalldjango=1.8.2报错: pipinstallMysqLdb-python CollectingMysqLdb-python Retrying(Retry(total=4,connect=None,read=None,redirect=None))afterconnectionbrokenby'ReadTimeoutError("HTTPSConnectionPool(host='pypi.python.org',port=443):Readtimedout.(readtimeout=15)",)':/simple/MysqLdb-python/ CouldnotfindaversionthatsatisfiestherequirementMysqLdb-python(fromversions:)NomatchingdistributionfoundforMysqLdb-python Youareusingpipversion8.1.1,howeverversion9.0.1isavailable. Youshouldconsiderupgradingviathe'pipinstall--upgradepip'command. 当安装中提示版本太低的时候,执行提示的命令进行升级即可 pipinstall--upgradepip升级完重新执行要安装的库原文链接:https://www.f2er.com/centos/375863.html