zoukankan      html  css  js  c++  java
  • centos7 python2.7.5 升级python3.6.4

    (转)Linux Centos7 升级python2至python3 - 依然范儿特西的文章 - 知乎 https://zhuanlan.zhihu.com/p/33660059

    1 查看python 版本

    python -V
    

    2 查看软连接指向

    ls -al /usr/bin/python
    

    3 重命名软连接

    mv /usr/bin/python /usr/bin/python2.7.5
    

    4 下载并解压 python

    wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
    tar -xf Python-3.6.4.tgz 
    

    5 安装python

    cd Python-3.6.4
    ./configure
    make
    make install
    

    到此,python3.6.4 已经安装到系统里了。 python2.7.5 由于软连接被重命名了。所以。你查看python 版本时候。会不存在。。

    命令 : python -V
    结果:  -bash: /usr/bin/python: No such file or directory
    

    如果带上刚才重命名的软连接即可使用

    6 让系统默认使用Python 3.6.4

    由于软连接指向被修改。此时 yum不能使用。需编辑一下 yum 的配置文件

    vi /usr/bin/yum
    

    把文件头部的

    #!/usr/bin/python
    

    改成

    #!/usr/bin/python2.7.5
    

    保存退出即可!

    7 建立新的链接

    rm -rf /usr/bin/python
    rm -rf /usr/bin/py
    ln -s /usr/local/bin/python3.6  /usr/bin/python
    

    8 验证是否成功

    python -V
    

  • 相关阅读:
    九度oj题目1019:简单计算器
    九度oj题目1555:重复子串
    Java泛型
    Remove Duplicates from Sorted Array
    Add Binary
    Plus One
    Remove Element
    Remove Nth Node From End of List
    Longest Common Prefix
    Roman to Integer
  • 原文地址:https://www.cnblogs.com/lza945/p/10133047.html
Copyright © 2011-2022 走看看