How to upgrade to python 3.7 on Ubuntu 18.10

In this article, we upgrade to python 3.7 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 But the latest version is Python 3.7.3.

So let’s start, First run this command to test the current version installed of python.

python3 -V

My current version is Python 3.6.5 but Yours may different.

upgrade-to-python3.7-current-python-version

Upgrade Python 3.7

Follow the simple steps to install and configure Python 3.7.

Step 1: Install the Python 3.7 package using apt-get

install python by typing below command :

sudo apt-get install python3.7
upgrade-to-python3.7-install-python

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

Also Read: Backup all MySQL Databases with a MySQL Backup Script

Step 3: Update Python 3 to point to Python 3.7

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

Type this command to configure python3:

sudo update-alternatives --config python3
upgrade-to-python3.7-configure-python3

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

Step 4: Test the version of python

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

python3 -V

You should get Python 3.7.1 as output.

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

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

Also Read: “How to install Ubuntu 18.04 LTS with screenshots

28 thoughts on “How to upgrade to python 3.7 on Ubuntu 18.10”

  1. I had Python 2.7 i followed the steps and made changes accordingly. When I type “python -V” it shows “Python 3.7.5” but when i execute Python It shows “Python 2.7”
    why?
    what should I do?
    I tried to make a change in the “update alternative” and “update config” but no luck

    Reply
    • How to change Python Version in Linux

      – python3 -V
      – Install python3.x (latest version)
      sudo apt install python3.x
      – Add Python 2.x & Python 3.x to update-alternatives
      sudo update-alternatives –install /usr/bin/python python /usr/bin/python2.x 1
      sudo update-alternatives –install /usr/bin/python python /usr/bin/python3.x 2

      NB: Remember to put no 2 your favorite python version you want to use in Linux

      – Update Python to point to Python 3.x(latest vesion)
      sudo update-alternatives –config python

      Choose no 2 (auto mode)

      – Test the version of python
      python -V

      Reply
      • now youre in problem. terminal use some kind python 2. and you disable it by your previous cmds. now go to the xterm(a another terminal in ubuntu you can download it from ubuntu centre) and enable the python 2

        Reply
      • I ran into the same problem. In Ubuntu 18.04, if you point to Python 3.7 as your primary, it will tank the terminal. I installed the “Sakura” terminal using Synaptic Package Manager and was able to run “sudo update-alternatives –config python3” and select Python 3.6. This fixed the problem.

        Reply
      • in case you don’t find the solution yet…
        try this:
        sudo rm /usr/bin/python3
        sudo ln -s python 3.7 /usr/bin/python3

        3.7 ex. is your old version

        Reply
  2. Same question here as Rhine was saying.
    ” … when i execute Python It shows “Python 2.7”
    why?
    what should I do?
    …”

    Reply
    • Same. My OS shipped with 2.7 & 3.6..
      I use Elementary OS which is based off of Ubuntu. Doing “`python -V“` gives me 2.7, and “`python3 -V“` gives 3.7. :L

      Reply
  3. concerning Rhine’s question of how to execute python as python3 I found the following:

    In console type

    1) python –version
    2) sudo update-alternatives –install /usr/bin/python python /usr/bin/python3 1
    3) python –version again to confirm the changes.

    Reply
  4. First of all, this is not an upgrade, but an update (from ver. 3.xx to 3.yy). And by an update, one understands replacing the old version of a program with a new one.
    The entire explanation here is not about how to perform such an update, but how to install yet another version of Python next to the old one! If one wants to keep up with all the updates (versions & sub-versions), he/she will end up with with a myriad of installations of the same program cluttering the computer!
    I understand Linux is not Windows, where such a program may look for and install updates automatically, without a sweat, but still, why do we have to keep the old version of python?!

    Reply
  5. Hi, I get this “ModuleNotFoundError: No module named ‘pip._internal’ while upgrading pip after upgrading python from 3.5.2 to 3.7.7.
    any idea please?

    Reply
  6. I tried this but then I broke my system, I wasn’t even able to start a new terminal. I had to boot in recovery mode to reverse back to python 3.6 (I’m on Linux Mint 19 Tara).

    Reply

Leave a Comment