Unable to set default python version to python3 in ubuntu

后端 未结 19 1749
遥遥无期
遥遥无期 2020-11-28 01:38

I was trying to set default python version to python3 in Ubuntu 16.04. By default it is python2 (2.7). I followed below steps :

19条回答
  •  遥遥无期
    2020-11-28 02:05

    To change Python 3.6.8 as the default in Ubuntu 18.04 to Python 3.7.

    Install Python 3.7

    Steps to install Python3.7 and configure it as the default interpreter.

    1. Install the python3.7 package using apt-get

      sudo apt-get install python3.7

    2. Add Python3.6 & Python 3.7 to update-alternatives

    sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
    sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2
    
    1. Update Python 3 to point to Python 3.7

      sudo update-alternatives --config python3 Enter 2 for Python 3.7

    2. Test the version of python

    python3 --version
    Python 3.7.1 
    

提交回复
热议问题