In this article, we upgrade to
python 3.7 from
python 3.6 and configure it
as the default version of python.
I was just trying to upgrade my python and I find it a little bit hard to do.
Python 3.6 is the default version that comes with Ubuntu 18.04/18.10 But the latest
version is Python 3.8. So it would be better to upgrade one major version.
So lets start; first run below command to test the current version installed of python.
$ python3 --version
Output will be like:
Step 1: Install Python3.7
Install pyhton by typing:
# sudo apt update -y $ sudo apt install python3.7
Step 2: Add Python 3.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
Step 3: Update Python 3 to point to Python 3.7
Python 3.6 is pointed to
Python 3. That means when we run
will execute as
python3.6 binary but we want to execute this as
Type this command to configure
$ sudo update-alternatives --config python3
You should get the above output. Now type 2 and hit enter for
Remember the selection number may differ so choose the selection number which is
Alternative Update Python 3 to point to Python3.7
/usr/bin/python3 is just a
symlink. Delete it and make a new
$ sudo rm /usr/bin/python3 $ sudo ln -s python3.7 /usr/bin/python3
Step 4: Test the version of python3
$ python3 -V