How to Install Python 3.7.2 in Ubuntu 18.04 LTS

1 min


This beginner’s tutorial explains the steps to install Python 3.7.2 in Ubuntu 18.04 LTS.

Ubuntu 18.04 LTS comes with Python 2.7 and 3.6 out of the box. However, you can install the latest Python 3.7.2 via ToolChain PPA in Ubuntu.

How to Install Python 3.7.2 in Ubuntu 18.04 LTS

  • Open terminal (CTRL+ALT+T).
  • Add the ToolChain PPA.
sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
sudo apt update
  • Run below command to install Python 3.7
sudo apt install python3.7

Follow the above same steps for Linux Mint 19.x as well.

As the PPA contains other packages such as gcc, c++, you might want to remove it from the Software and Updates in Ubuntu. Open Software and Updates app and go to Other Softwares tab. Then select the PPA and click remove.

To make python3 use the installed python 3.7.2 instead of Python 3.6.x, you have to add it as a choice by running below commands. This command adds the options for both the version and helps you to switch as per your need.

Python 3.7 in Ubuntu 18.04
Python 3.7 in Ubuntu 18.04
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

To switch

sudo update-alternatives --config python3

The above last step might create issues in certain system apps in Ubuntu 18.04. If you find that the latest Python 3.7 caused some system applications such as Terminal, Software, and Updates utility not running, then follow the below steps.

  • Press ALT+F2 and type XTERM.
  • In the XTERM terminal, type
sudo update-alternatives --config python3

And choose Python 3.6 and close.


Arindam

Creator and author of debugpoint.com. Connect with me via Telegram, ๐• (Twitter), or send us an email.
Subscribe
Notify of
guest

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

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments