• CentOS安装python-2.7+安装pip-10.0.0


    注:以下所有操作均在CentOS 6.8 x86_64位系统下完成。

    首先查看当前系统预装的python版本:

    # whereis python
    python2: /usr/bin/python2 /usr/bin/python2.6 /usr/lib/python2.6 /usr/lib64/python2.6 /usr/include/python2.6
    # pthyon --version
    Python 2.6.6
    # cd /usr/bin
    # ls -l python*
    -rwxr-xr-x 2 root root 4864 Aug 18  2016 python
    lrwxrwxrwx 1 root root    6 Aug 24  2017 python2 -> python
    -rwxr-xr-x 2 root root 4864 Aug 18  2016 python2.6

    系统默认安装的是python-2.6.6,由于2.6版本已经不再被支持,所以这里将其升级成2.7版本。

    #安装python#

    开始下载python并进行编译安装:

    # wget https://www.python.org/ftp/python/2.7/Python-2.7.tgz
    # tar zxf Python-2.7.tgz
    # cd Python-2.7
    # ./configure --prefix=/usr/local/python-2.7
    # make && make install

    然后配置环境替换默认的python-2.6:

    # vim /etc/profile
    
    ...
    export PY_HOME=/usr/local/python-2.7
    export PATH=$PY_HOME/bin:$PATH
    ...
    # source /etc/profile
    # python --version
    Python 2.7

    重新指向python2的软链:

    # rm -f /usr/bin/python2
    # ln -s /usr/local/python-2.7/bin/python /usr/bin/python2

    至此,python安装完毕。

    #安装pip#

    首先查看当前的pip的版本:

    # whereis pip
    pip: /usr/bin/pip /usr/bin/pip2.6
    # pip --version
    pip 9.0.1 from /usr/lib/python2.6/site-packages (python 2.6)

    当前的pip是python2.6的,所以同样需要升级安装。

    首先需要安装setuptools:

    # wget https://files.pythonhosted.org/packages/72/c2/c09362ab29338413ab687b47dab03bab4a792e2bbb727a1eb5e0a88e3b86/setuptools-39.0.1.zip
    # unzip setuptools-39.0.1.zip
    # cd setuptools-39.0.1
    # python setup.py install
    ...
    Installed /usr/local/python-2.7/lib/python2.7/site-packages/setuptools-39.0.1-py2.7.egg
    Processing dependencies for setuptools==39.0.1
    Finished processing dependencies for setuptools==39.0.1

    然后安装pip:

    # wget https://files.pythonhosted.org/packages/e0/69/983a8e47d3dfb51e1463c1e962b2ccd1d74ec4e236e232625e353d830ed2/pip-10.0.0.tar.gz
    # tar zxf pip-10.0.0.tar.gz
    # cd pip-10.0.0
    # python setup.py install
    ...
    Installed /usr/local/python-2.7/lib/python2.7/site-packages/pip-10.0.0-py2.7.egg
    Processing dependencies for pip==10.0.0
    Finished processing dependencies for pip==10.0.0

    然后配置环境替换默认的pip:

    # which pip
    /usr/local/python-2.7/bin/pip
    # source /etc/profile
    # pip --version
    pip 10.0.0 from /usr/local/python-2.7/lib/python2.7/site-packages/pip-10.0.0-py2.7.egg/pip (python 2.7)

    至此,安装完成。

  • 相关阅读:
    一:ORM关系对象映射(Object Relational Mapping,简称ORM)
    How to manage concurrency in Django models
    python实现redis三种cas事务操作
    django autocommit的一个坑,读操作的事务占用导致锁表
    Unity3d载入外部图片文件
    MySQL 查询某个列中同样值的数量统计
    Android_自己定义切换控件SwitchView
    SWTBOK測试实践系列(5) -- 项目中使用手动和自己主动化的策略
    自己定义一个Dialog样式的Activity窗体,切换到Dialog的方法
    搜狗语音云开发入门(二)——使用离线语音识别服务
  • 原文地址:https://www.cnblogs.com/brishenzhou/p/8884515.html
Copyright © 2020-2023  润新知