How to upgrade to python 3.7 on ubuntu 18.10

How to upgrade to python 3.7 on ubuntu 18.10

Ubuntu 18.10 ships with python 3.6.7, here is how to install python 3.7 and configure it as the default version of python

Before getting started, run the following command to see what version of python3 you are running.

python3 -V
Python 3.6.7

NOTE: Some comments below have warned that using update-alternatives to switch from python 3.6 to python 3.7 will cause problems for some (Ubuntu Desktop) GUI applications that are linked to python 3.6. This guide is targeted at non-graphical ubuntu servers and works great as far as I’ve tested.

You can still install and use python 3.7 on Ubuntu Desktop machine just skip the update-alternatives steps below. To use 3.7 instead of 3.6 just execute python3.7 directly, create a virtualenv or use pipenv.

Install Python 3.7

Steps to install python3.7 and configure it as the default python3 interpreter.

  1. Install the python3.7 package using apt-get

    sudo apt-get install python3.7

    apt install python3.7

  2. Add python3.6 & python3.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

  3. Update python3 to point to python3.7

    sudo update-alternatives --config python3
    Enter 2 for python3.7

    update-alternatives python3

  4. Test the version of python

    python3 -V
    Python 3.7.1

    python 3.7 REPL

Now you should have the latest stable version of python running on your Ubuntu linux server. Leave a comment below and checkout my other linux tutorials.

DigitalOcean offers one-click deployment of popular applications such as WordPress, Django, MongoDB, Docker, and even preconfigured Kubernetes Clusters. Deploy your next app in seconds. Get $100 in cloud credits from DigitalOcean

Ad Notice I will receive a small commission that helps support this blog at no cost to you.

24 Replies to “How to upgrade to python 3.7 on ubuntu 18.10”

  1. Man you’re awesome. Thank you for this. I’m new to Ubuntu and feel like posts like these are invaluable to me. I tried installing with instructions from python’s site and kept getting errors. Maybe because of the version number? I don’t know, this worked though and I’m grateful for it.

  2. After updating python3 to point to python3.7, I am getting ModuleNotFoundError using pip3, how should I also install pip3 for python3.7?

  3. If you update Python to latest version (3.7.3 at the moment) on Ubuntu 18, your native terminal won’t load. This article is helpful but not completed!

    1. Although I installed Python 3.7.1 my native terminal stopped working and my computer could not receive updates so I had to return Python 3.6 as the default python3 interpreter.

    2. yes! Terminal has a fit if the python3 symlink points to python 3.7. Why is this? Why does ubuntu 18.04 REQUIRE that the symlink, python3, point to python3.6? Is python 3,7 THAT different??

      1. Using update-alternatives to change python3 is not advisable a Ubuntu Desktop 18.10. As far as I’ve tested it works on non-gui ubuntu server installs.

        1. If you’ve already “broken” your native terminal by setting your update-alternatives to 3.7, try this:
          -Ctrl-Alt-F1 (this will switch you into the virtual console)
          -Plug in your system username and password
          -Enter the following: sudo update-alternatives –config python3
          -Select the option 1, for python 3.6
          -Ctrl-alt-F7 to return back to the GUI
          Your native terminal should work after this :-)

  4. Please take down this article or at least amend it, this solution breaks terminal and the software update because it messes with default ubuntu config, check stackoverflow.

    1. This problem you describe is only on full gui installs of ubuntu but update-alternatives works great for non-gui servers. I have added a warning note at the top of the article.

  5. I did this without reading the note at the top and it really screwed me up. Hopefully people don’t do the same thing I did!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.