• Unbuntu系统下,切换python版本


    Unbuntu系统下,安装了python2.7和python3.6
    在正常用户模式下,输入如下命令:
    python --version , 或者python
    会显示当前使用的python版本号

    按照目前网上多python版本切换的方案,使用
    update-alternatives --config python
    的方式,在root模式下可以正常切换,但是在当前用户模式下无法完成切换。

    所以翻遍了网上的资料,在用户模式下,直接vi ~/.bashrc

    # Alias definitions.
    # You may want to put all your additions into a separate file like
    # ~/.bash_aliases, instead of adding them here directly.
    # See /usr/share/doc/bash-doc/examples in the bash-doc package.
    
    if [ -f ~/.bash_aliases ]; then
        . ~/.bash_aliases
    fi
    
    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if ! shopt -oq posix; then
      if [ -f /usr/share/bash-completion/bash_completion ]; then
        . /usr/share/bash-completion/bash_completion
      elif [ -f /etc/bash_completion ]; then
        . /etc/bash_completion
      fi
    fi
    
    export REPO_URL='http://192.168.100.209:8080/git-repo'
    alias python=python2
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24

    alias python=python2 这里,修改成python2,或者python3
    保存之后,source ~/.bashrc,再次运行python,则python版本跟着修改一起变化。

    至于为什么update-alternatives --config python 修改没反应,期待各位大神帮忙解答~

  • 相关阅读:
    2021论文阅读笔记集合
    8、表格标签
    yocto(六)——搭建yocto环境
    安装CentOS7虚拟机
    前端 - get请求传递数组
    Vue2 —— vue面试题分享
    这次把怎么做好一个PPT讲清-画图篇
    XTU-OJ 1255-勾股数
    Spring Boot 自定义starter
    Android 10.0 Settings主页面去掉FocusRecyclerView相关功能
  • 原文地址:https://blog.csdn.net/happyhenji1213/article/details/128097002