How to update-alternatives to Python 3 without breaking apt?

前端 未结 4 479
忘掉有多难
忘掉有多难 2020-12-01 03:01

The other day I decided that I wanted the command python to default to firing up python3 instead of python2.

So I did this:

$ sudo update-alternative         


        
4条回答
  •  自闭症患者
    2020-12-01 03:23

    As I didn't want to break anything, I did this to be able to use newer versions of Python3 than Python v3.4 :

    $ sudo update-alternatives --install /usr/local/bin/python3 python3 /usr/bin/python3.6 1
    update-alternatives: using /usr/bin/python3.6 to provide /usr/local/bin/python3 (python3) in auto mode
    $ sudo update-alternatives --install /usr/local/bin/python3 python3 /usr/bin/python3.7 2
    update-alternatives: using /usr/bin/python3.7 to provide /usr/local/bin/python3 (python3) in auto mode
    $ update-alternatives --list python3
    /usr/bin/python3.6
    /usr/bin/python3.7
    $ sudo update-alternatives --config python3
    There are 2 choices for the alternative python3 (providing /usr/local/bin/python3).
    
      Selection    Path                Priority   Status
    ------------------------------------------------------------
    * 0            /usr/bin/python3.7   2         auto mode
      1            /usr/bin/python3.6   1         manual mode
      2            /usr/bin/python3.7   2         manual mode
    
    Press enter to keep the current choice[*], or type selection number: 1
    update-alternatives: using /usr/bin/python3.6 to provide /usr/local/bin/python3 (python3) in manual mode
    $ ls -l /usr/local/bin/python3 /etc/alternatives/python3 
    lrwxrwxrwx 1 root root 18 2019-05-03 02:59:03 /etc/alternatives/python3 -> /usr/bin/python3.6*
    lrwxrwxrwx 1 root root 25 2019-05-03 02:58:53 /usr/local/bin/python3 -> /etc/alternatives/python3*
    

提交回复
热议问题