I did:
sudo apt-get upgrade python3
and then:
python3 --version
but still shows: Python 3.5.2, where I was expecting Python 3.7.3 which is the latest version so far.
Why and what happened here?
Can someone please explain in detail about this?
Many Linux distros still link /usr/bin/python
to python2
rather than python3
. If you just want to casually run Python 3, type python3
on the command-line. Use pip3
to install packages for that interpreter when you would normally use pip
.
What I would not recommend doing is using your sudo powers to update the python
symlink. There are too many system scripts that rely on /usr/bin/python
being python2
for this to be a good idea.
If you want finer-grained control over Python interpreters, use a platform manager like Anaconda or Miniconda. Unlike normal Ubuntu packages, you can install it for the local user, so it won't require root access to maintain. You can also point your PATH
variable to include the Anaconda version of python
first, without affecting the rest of the system at all. Here is an example of installation instructions: https://www.digitalocean.com/community/tutorials/how-to-install-anaconda-on-ubuntu-18-04-quickstart.
For even more manual control, use virtualenvs.
Going the other way, the simplest solution might be to just define an alias for python
in your .bashrc
.