zoukankan      html  css  js  c++  java
  • ubuntu16.04同时使用 pyhton2.7和3.5,并随意切换

    ubuntu16.04中默认已经安装了python2.7和python3.5

    hanli@ubuntu:/usr/bin$ ls |grep python
    dh_python2
    dh_python3
    python
    python2
    python2.7
    python2.7-config
    python2-config
    python3
    python3.5
    python3.5m
    python3m
    python-config
    x86_64-linux-gnu-python2.7-config
    x86_64-linux-gnu-python-config
    

    怎么切换?

    1.现在是2.7

    hanli@ubuntu:/usr/bin$ python
    Python 2.7.12 (default, Nov 19 2016, 06:48:10) 

    2.执行两条命令

    hanli@ubuntu:/usr/bin$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
    update-alternatives: using /usr/bin/python2 to provide /usr/bin/python (python) in auto mode
    hanli@ubuntu:/usr/bin$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
    update-alternatives: using /usr/bin/python3 to provide /usr/bin/python (python) in auto mode

    3.再次查看已经变成3.5了

    hanli@ubuntu:/usr/bin$ python
    Python 3.5.2 (default, Nov 17 2016, 17:05:23) 

    4.怎么随意切换

    hanli@ubuntu:/usr/bin$ sudo update-alternatives --config python
    There are 2 choices for the alternative python (providing /usr/bin/python).
    
      Selection    Path              Priority   Status
    ------------------------------------------------------------
    * 0            /usr/bin/python3   150       auto mode
      1            /usr/bin/python2   100       manual mode
      2            /usr/bin/python3   150       manual mode
    
    Press <enter> to keep the current choice[*], or type selection number: 1
    update-alternatives: using /usr/bin/python2 to provide /usr/bin/python (python) in manual mode
    
    #数字前面有*号表示是当前使用版本,输入1切换到2.7,再次查看如下
    
    hanli@ubuntu:/usr/bin$ sudo update-alternatives --config python
    There are 2 choices for the alternative python (providing /usr/bin/python).
    
      Selection    Path              Priority   Status
    ------------------------------------------------------------
      0            /usr/bin/python3   150       auto mode
    * 1            /usr/bin/python2   100       manual mode
      2            /usr/bin/python3   150       manual mode
    
    Press <enter> to keep the current choice[*], or type selection number:
  • 相关阅读:
    TP5.1:request请求对象(使用四种方式获取)
    TP5.1:facade静态代理
    php:定义时间跳转到指定页面
    TP5.1:依赖注入、绑定一个类到容器里、绑定一个闭包到容器中
    sql:表中数据全部删除之后,重新插入时,从1开始增加
    通过CSS3实现:鼠标悬停图片360度旋转效果
    TP5.1 配置的获取与设置
    详细讲解:通过composer安装TP5.1(Thinkphp5.1)
    TP5.0: 显示错误信息
    socket2
  • 原文地址:https://www.cnblogs.com/fanren224/p/8457238.html
Copyright © 2011-2022 走看看