skip to Main Content

The debian I am using has its default python3 -> 3.7.3.
Then I successfully installed the python3 version 3.7.4, which is a dedicated version I prefer to.

But now, the python version goes to mess.
Here is the detailed info from terminal commands

  1. python3 –version
    –> Python 3.7.4
  2. /usr/bin/python3 — version
    –> Python 3.7.3
  3. /usr/bin/python3.7 — version
    –> Python 3.7.3

So how can I align it with "Python 3.7.4"?

2

Answers


  1. If you have a look into /usr/bin, you will see, that you’ll have many different executables for different python versions, e.g. python2.7, python3.7.3, python3.7.4, etc.

    To give users the security of a known environment, you’ll also find symbolic links, e.g.

    lrwxrwxrwx  1 root    root           9 Okt 18  2016 python -> python2.7*
    lrwxrwxrwx  1 root    root           9 Okt 18  2016 python2 -> python2.7*
    -rwxr-xr-x  1 root    root     3546104 Nov 19 10:35 python2.7*
    ...
    lrwxrwxrwx  1 root    root           9 Okt 18  2016 python3 -> python3.5*
    -rwxr-xr-x  2 root    root     4460336 Nov 17 20:23 python3.5*
    

    So in the example the commands python and python2 will both execute python2.7. Calling python3 will actually execute python3.5.

    I usually change those symbolic links to fit my needs (you might need root rights). For example, I usually want the command python to run the current python3 version:

    cd /usr/bin
    ln -sf python3 python
    

    Why calling python3 --version results in version 3.7.4 must further be examined:

    1. What does which python3 show?
    2. Have you defined any aliases (e.g. alias python="/usr/bin/python3.7.4" in your .bashrc file)
    Login or Signup to reply.
  2. What AnsFourtyTwo said is correct, but if you need to manage multiple Python versions, try to use pyenv.

    It’s a tool that lets to manage multiple Python versions (and implementations) on your machine and switch between them easily so that you won’t have to change the links manually.

    It’s similar to nvm (Node.js version manager).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search