Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views :

How to upgrade to Python 3.8 on Ubuntu 18.04 LTS


In this article, we will upgrade to python 3.8 and configure it as the default version of python.

The current stable version of python released on 14 Oct. 2019. Many ubuntu users are facing problems during upgrading python to the latest version. Python 3.6.9 available as default when we install Ubuntu 18.04 LTS. Python 3.8 is not available in default Ubuntu 18 repositories.

Also Read: How to upgrade to Python 3.7 on Ubuntu 18.10

So let’s start with checking the currently installed version of Python on your system.

python3 -V

As seen in the image above, my currently installed Python version is 3.6.9 but yours may differ.

Install Python 3.8

Follow the simple steps to install and configure Python 3.8

Step 1: Add the repository and update

Latest Python 3.8 not available in Ubuntu’s default repositories. So, we have to add an additional repository. On launchpad repository named deadsnakes is available for Python Packages.

Add the deadsnakes repository using the below commands.

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update

Update the package list using the below command.

apt-get update

Verify the updated Python packages list using this command.

apt list | grep python3.8

As seen in the image above, Now we have Python 3.8 available for installation.

Step 2: Install the Python 3.8 package using apt-get

install Python 3.8 by using the below command :

sudo apt-get install python3.8

Step 3: Add Python 3.6 & Python 3.8 to update-alternatives

Add both old and new versions of Python 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.8 2

Step 4: Update Python 3 for point to Python 3.8

By default, Python 3 is pointed to Python 3.6. That means when we run python3 it will execute as python3.6 but we want to execute this as python3.8.

Type this command to configure python3:

sudo update-alternatives --config python3

You should get the above output. Now type 2 and hit enter for Python 3.8. Remember the selected number may differ so choose the selection number which is for Python 3.8.

Step 5: Test the version of python

Finally, test the current version of python by typing this :

python3 -V

You should get Python 3.8 as output.


In this article, we learn how to upgrade python to the latest version that is 3.8 in Ubuntu 18.10.

Share your thoughts in the comment section. Happy Learning …!!

  • Facebook
  • Twitter
  • Google+
  • Linkedin
  • Pinterest


  1. This didn’t work for me… I read the article and follow all the steps, then the terminal wouldn’t launch.. I believe the problem occurred because I set python up with anaconda (The cadillac of open-source python distros).
    If this happens to you, open xterm (since we can’t access the terminal right now). Then run ‘sudo update-alternatives –config python3’ and choose the old version of python (3.6 in this case). Now the terminal can open like normal, but we still haven’t installed python 3.8.
    this will work for 18.04 as well]

    There is a way better way to install python 3.8 that is much easier (requires conda):
    0) navigate to your home directory
    1) run ‘sudo apt-get remove python3.8’, to undo the damage done by this article.
    2) run ‘conda create -n py38 anaconda=2020.02 python=3.8’
    3) finally after all the packages are installed run ‘conda activate py38’, in fact conda will prompt you to do so with instructions!

    Now you have installed py38 to your python3 path, additionally it is the active environment. We can check this by entering the command ‘python3 -V’ or equivalently ‘python3 –version’ (same same). Either command should print: ‘Python 3.8.1’, as desired.

    Hopefully if you run into the same problem as I did that this solves your issue.

    I think the lesson to learn here is to trust stack exchange to have an answer, just my require some digging, but every question seems to have been asked with wonderful answers and comments on answers (where all the true gems are to be found).

  2. Fantastic! Clear and simple directions that were easy to follow and explained everything I needed / wanted to know, and nothing that I didn’t. Thank-you!

  3. I agree to the warnings of some other people. This tutorial broke my system. Please just use Anaconda to upgrade Python and do not mess with `sudo update-alternatives` if you do not know exactly what you are doing.

  4. Excellent post. I used to be checking constantly this blog and I’m inspired!

    Extremely useful info particularly the last part 🙂 I take care of such information a lot.
    I used to be seeking this certain information for a very long time.

    Thanks and best of luck.

  5. I can change according to your instructions. After switching to Python 3.8, I can do “sudo apt-get update”. There is an error showing:

    Fetched 6,916 kB in 7s (933 kB/s)
    Traceback (most recent call last):
    File “/usr/lib/cnf-update-db”, line 8, in
    from CommandNotFound.db.creator import DbCreator
    File “/usr/lib/python3/dist-packages/CommandNotFound/db/”, line 11, in
    import apt_pkg
    ModuleNotFoundError: No module named ‘apt_pkg’
    Reading package lists… Done
    E: Problem executing scripts APT::Update::Post-Invoke-Success ‘if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi’
    E: Sub-process returned an error code
    May I know what is this error and how to fix it? When I switched back to python 3.6, I can update.

Leave a Comment

Your email address will not be published. Required fields are marked *

This div height required for enabling the sticky sidebar