0

I using Ubuntu 16.04 and I currently have 3 Python versions installed: Python 2.7, 3.5 and 3.6. I have a question relating to the /etc/alternatives/python shortcut.

Here is some brief context:

ls -l /usr/bin/python*

# Output:
/usr/bin/python -> /etc/alternatives/python
/usr/bin/python2 -> python2.7
/usr/bin/python2.7
/usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
/usr/bin/python2-config -> python2.7-config
/usr/bin/python3 -> python3.6
/usr/bin/python3.5
/usr/bin/python3.5-config -> x86_64-linux-gnu-python3.5-config
/usr/bin/python3.5m
/usr/bin/python3.5m-config -> x86_64-linux-gnu-python3.5m-config
/usr/bin/python3.6
/usr/bin/python3.6m
/usr/bin/python3-config -> python3.5-config
/usr/bin/python3m -> python3.5m
/usr/bin/python3m-config -> python3.5m-config
/usr/bin/python-config -> python2.7-config

I successfully mapped the "python3" shortcut (which initially open up Python 3.5) to 3.6 by typing:

sudo ln -s python3.6 python3

And my first output clearly shows this has worked. From what I understand, using the "ln -s" creates a symbolic link between the command "python3" and the /usr/bin/python3.6 so that when I type "python3", my computer knows I mean /user/bin/python3.6.

My question is: why the shortcut different for " /usr/bin/python -> /etc/alternatives/python". I have seen people use the following command to change the mapping for "python":

sudo update-alternatives --config python

# My output in this case:
[sudo] password for m93: 
There are 3 choices for the alternative python (providing /usr/bin/python).

Selection    Path                Priority   Status
------------------------------------------------------------
  0          /usr/bin/python3.6   2         auto mode
* 1          /usr/bin/python2.7   1         manual mode
  2          /usr/bin/python3.5   1         manual mode
  3          /usr/bin/python3.6   2         manual mode

From what I understand,this means that python 2.7 is corresponds to "python". But:

  • Why is such a different way to mapping "python3"?
  • what does manual vs auto mode mean?
  • What do the priority levels mean?

UPDATE

I didn't really know what I was doing when I made this /etc/alternatives/python but I followed the instructions from this link https://unix.stackexchange.com/questions/410579/change-the-python3-default-version-in-ubuntu

Briefly, this involved: From the comment:

$ sudo update-alternatives --config python
#Will show you an error: update-alternatives: error: no alternatives for python3 

$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 1
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
$ sudo update-alternatives --config python

However, somewhere along the line, I got confused and ended up with the output shown above. Can I just get rid of the /etc/alternatives/python?

Many thanks.

4
  • 1
    /usr/bin/python is not a part of the Debian alternatives system on a default Ubuntu - that must be something you did yourself. What exactly did you do to your Python setup? As for manual vs auto, see: askubuntu.com/a/910190/158442. Priority is just a number used by the alternatives system for auto mode. – muru Dec 10 '18 at 11:58
  • Are you saying I could remove this /etc/alternatives/python? If so, can I just type "$ rm python"? Just wanna make sure I am not remove an actual Python installation but just the symbolic link. Would that work? I would rather keep things simple (i didn't really know what i was doing when i created this alternative thing) so would rather keep some simple symbolic links like for "/usr/bin/python3 -> python3.6" – mf94 Dec 10 '18 at 12:15
  • No, that's not what I said at all. Please describe how you got your system in this state first. – muru Dec 10 '18 at 12:16
  • Just put an update with some details, hope it helps – mf94 Dec 10 '18 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.