Do you need Ubuntu 20.04? Ubuntu 18.04 comes with Python 3.6, and 3.7 available.

If you do, the deadsnakes PPA has Python 3.5-3.7 for Ubuntu 20.04 (Focal). To add it and install:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get install python3.7

P.s. I'm not a dev and have no experience with Tensorflow so take this with a grain of salt.

(Sidenote: add-apt-repository runs apt-get update automatically, but that's not documented in man add-apt-repository, only add-apt-repository --help. This was fixed in a later release.)

Answer from wjandrea on Stack Overflow
Top answer
1 of 2
37

For newer Python I prefer the deadsnake ppa. For installing it, try this:

sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.7
$ python3.7 -V
Python 3.7.7
2 of 2
4

The Python 3.7 package from the official Ubuntu 19.10 repositories can be installed in Ubuntu 20.04 without adding any new repositories to your software sources by running the following commands:

sudo apt update  
wget -c http://mirrors.kernel.org/ubuntu/pool/main/libf/libffi/libffi6_3.2.1-9_amd64.deb http://security.ubuntu.com/ubuntu/pool/main/p/python3.7/libpython3.7-stdlib_3.7.5-2~19.10ubuntu1_amd64.deb http://security.ubuntu.com/ubuntu/pool/main/p/python3.7/libpython3.7-minimal_3.7.5-2~19.10ubuntu1_amd64.deb http://security.ubuntu.com/ubuntu/pool/main/p/python3.7/python3.7-minimal_3.7.5-2~19.10ubuntu1_amd64.deb http://security.ubuntu.com/ubuntu/pool/main/p/python3.7/python3.7_3.7.5-2~19.10ubuntu1_amd64.deb
sudo apt install ./libffi6_3.2.1-9_amd64.deb ./libpython3.7-minimal_3.7.5-2~19.10ubuntu1_amd64.deb ./libpython3.7-stdlib_3.7.5-2~19.10ubuntu1_amd64.deb ./python3.7-minimal_3.7.5-2~19.10ubuntu1_amd64.deb ./python3.7_3.7.5-2~19.10ubuntu1_amd64.deb

Add Python 3.7 to update-alternatives so that you can switch between Python 3.8 and Python 3.7 by running update-alternatives --config python3.

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7
update-alternatives --config python3
Discussions

Help with installing python 3.7
Which Distro are you running on the Pi? Maybe you need to add a repository first if no python 3.7 is available in the default repos. Also check which Version of python do you have by putting this in a Script and run it: https://stackoverflow.com/questions/1093322/how-do-i-check-what-version-of-python-is-running-my-script#1093331 More on reddit.com
🌐 r/linux4noobs
7
2
April 27, 2020
I need to use python 3.7 but Ubuntu 20.4 comes with 3.8 pre-installed - can I install it with apt-get alongside 3.8?
In your case, I would install anaconda to not rely on the system installed python packages. You could have any version you wanted. More on reddit.com
🌐 r/Ubuntu
6
3
July 9, 2020
Install python 3.11.9 on ubuntu
According to this page: 'Python 3.11.9 is the newest major release of the Python programming language". Can I install Python 3.11.9 in my Virtual Machine? I have installed guest VM ubuntu-22.04.4-desktop-amd64.iso on a Windows 10 host. In the VM, I have run the following: sudo apt install sudo ... More on discuss.python.org
🌐 discuss.python.org
12
1
April 16, 2024
ubuntu - How to install specific python version? - Unix & Linux Stack Exchange
I'm trying to install Python 3.7.0 on WSL (Ubuntu 20.04). Tried: sudo apt install python3.7.0 But it says that there is no such package. Using: sudo apt install python3.7 installs python 3.7.9 an... More on unix.stackexchange.com
🌐 unix.stackexchange.com
November 30, 2020
🌐
Linuxize
linuxize.com › home › python › how to install python 3.7 on ubuntu 18.04
How to Install Python 3.7 on Ubuntu 18.04 | Linuxize
October 15, 2019 - This tutorial describes two ways of installing Python 3.7 on Ubuntu 18.04: By using the standard apt tool from the deadsnakes PPA, and by building from the source code.
🌐
GitHub
gist.github.com › j40903272 › a4b715b79b2e5aa74342fe995a1c1ef9
Install python3.7 · GitHub
python3 -V apt update sudo apt install software-properties-common sudo add-apt-repository ppa:deadsnakes/ppa apt update ... wget https ://www.python.org/ftp/ptar xvf python -3.7.0.tar .xx cd /tmp/python 37/python-3.7.0./configure sudo make altinstall
Find elsewhere
🌐
GitHub
gist.github.com › Sdoof › 6c6b38fe238cea5768b50ce4def7c6c3
Install Python 3.7 and pip, pipenv on Ubuntu 18.04 (works on WSL).md · GitHub
Register both Python 3.7 and and preinstalled Python 3.6 to python3 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
🌐
Python
python.org › downloads › release › python-370
Python Release Python 3.7.0 | Python.org
Note: The release you are looking at is Python 3.7.0, the initial feature release for the legacy 3.7 series which has now reached end-of-life and is no longer supported. See the downloads page for currently supported versions of Python.
🌐
GitHub
gist.github.com › simonw › 7d391ec1fdddd730e0075d963da65f1f
How to run Python 3.7 on Ubuntu 16.04 · GitHub
As my app (to be migrated from Raspberry Pi) is made for 3.7, I chose to download that version, and it worked well. The new version was installed into /usr/local/bin/python, so I've then run: $ sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3 $ update-alternatives --config python · to link /usr/bin/python to it (should it break anything in this old Ubuntu, it'll be very easy to revert using the latter command).
🌐
Reddit
reddit.com › r/ubuntu › i need to use python 3.7 but ubuntu 20.4 comes with 3.8 pre-installed - can i install it with apt-get alongside 3.8?
r/Ubuntu on Reddit: I need to use python 3.7 but Ubuntu 20.4 comes with 3.8 pre-installed - can I install it with apt-get alongside 3.8?
July 9, 2020 -

Sorry for the dumb question. Just installed a fresh Ubuntu 20.4 after a couple of years of not touching Linux. I thought I could just sudo apt-get install python3.7 but that doesn't work.

I'd love to be able to use apt-get to minimize the chances I fuck something up, can I do this without having to download and compile it myself?

More specifically:

When I sudo apt-get install python 3.7 I don't get any errors or anything, I just get the following:

$ sudo apt-get install python3.7
[sudo] password for j: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'python3.7-2to3' for regex 'python3.7'
Note, selecting 'libpython3.7-stdlib' for regex 'python3.7'
0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.

Then when I python3.7 I get:

$ python3.7

Command 'python3.7' not found, did you mean:

  command 'python2.7' from deb python2.7 (2.7.18~rc1-2)
  command 'python3.8' from deb python3.8 (3.8.2-1ubuntu1.1)

Try: sudo apt install <deb name>

And if I look in /usr/bin/:

$ ls /usr/bin/ | grep python
python3
python3.8

And:

$ ls -l /usr/bin/python*
lrwxrwxrwx 1 root root       9 júl  8 23:57 /usr/bin/python3 -> python3.8
-rwxr-xr-x 1 root root 5457536 apr 27 15:53 /usr/bin/python3.8
🌐
Python.org
discuss.python.org › python help
Install python 3.11.9 on ubuntu - Python Help - Discussions on Python.org
According to this page: 'Python 3.11.9 is the newest major release of the Python programming language". Can I install Python 3.11.9 in my Virtual Machine? I have installed guest VM ubuntu-22.04.4-desktop-amd64.iso on a Windows 10 host. In the VM, I have run the following: sudo apt install sudo apt upgrade this: python3 --version returns: Python 3.10.12 When I run: sudo apt install python3 I receive this message: python3 is already at the newest version (3.10.6-1~22.04) When...
Published   April 16, 2024
🌐
Ubuntu
documentation.ubuntu.com › ubuntu-for-developers › reference › availability › python
Available Python versions - Ubuntu for Developers
April 5, 2026 - Installing Ubuntu Desktop for developers · Using Git version control on Ubuntu · Packaging software · Introduction to the .NET toolchain · Debugging with .NET · GraalVM native compilation · Contribute documentation · Back to top · Contribute to this page · This page lists Python versions available in Ubuntu releases. bold – package is in main · bold – package is in main · Contents · Available Python versions · Ubuntu Python 3 (deb) packages ·
Top answer
1 of 3
47

It would be wise to use pyenv to safely manage multiple versions of Python installed on the same system.

Nonetheless, this should get you up and running with Python 3.7.10 on Ubuntu 16.04

# WARNING: As of April 30th 2021, Ubuntu Linux 16.04 LTS will no longer supported
# NOTE: It appears that Python 3.7.* has arrived into maintenance mode and will likely
# only be getting security updates.  See release notes https://www.python.org/downloads/release/python-3710/

# Install requirements
sudo apt-get install -y build-essential \
checkinstall \
libreadline-gplv2-dev \
libncursesw5-dev \
libssl-dev \
libsqlite3-dev \
tk-dev \
libgdbm-dev \
libc6-dev \
libbz2-dev \
zlib1g-dev \
openssl \
libffi-dev \
python3-dev \
python3-setuptools \
wget

# Prepare to build
mkdir /tmp/Python37
mkdir /tmp/Python37/Python-3.7.10
cd /tmp/Python37/

# Pull down Python 3.7.10, build, and install
wget https://www.python.org/ftp/python/3.7.10/Python-3.7.10.tar.xz
tar xvf Python-3.7.10.tar.xz -C /tmp/Python37
cd /tmp/Python37/Python-3.7.10/
./configure --enable-optimizations
sudo make altinstall

Then you would just call Python like so:

python3.7 ./yourScript.py

This is a screenshot of multiple versions of Python co-existing in a docker container and how they can be distinguished:

Pip should have been installed with this installation as well. To install packages use this format:

pip3.7 -V
2 of 3
7

I would not recommend manually fiddling around with source code installations and paths. Use pyenv and save yourself the trouble.

All you have to do is:

  • Run the pyenv installer
  • Follow the instructions
  • Install the Python versions you need
  • Choose which Python version you want to use for a given directory, or globally

For example, to install 3.7, check which versions are available:

pyenv install -l | grep 3.7

Then run:

pyenv install 3.7.1

Now, you can choose your Python version:

pyenv global 3.7.1

This switches your python to point to 3.7.1. If you want the system python, run:

pyenv global system

To check which Python versions are available, run pyenv versions.

🌐
DedicatedCore
dedicatedcore.com › home › how to install python 3 on ubuntu 20.04
How to Install Python 3 on Ubuntu 20.04 - DedicatedCore Blog
October 16, 2024 - You can follow the instructions in this tutorial for Python installation on Ubuntu 18.04 or 20.04. Operating system scripts are typically written in the popular programming language Python. It is sufficiently adaptable to be used in both web development and app creation. You may learn how to install Python 3.8 on Ubuntu 18.04 | 20.04 here.
🌐
Antonio's IT Blog
antonioyan.wordpress.com › 2020 › 08 › 18 › how-to-install-python-3-7-on-ubuntu-debian-and-linuxmint
How to Install Python 3.7 on Ubuntu, Debian and LinuxMint | Antonio's IT Blog
August 18, 2020 - sudo apt-get install wget ... libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev · Download Python using following command from python official site....
🌐
Reddit
reddit.com › r/python › installing specific python version in ubuntu 20
r/Python on Reddit: Installing specific python version in Ubuntu 20
June 21, 2020 -

Beginners beware, this post isn't about overwriting the default python installation, but working with alternative installation of other versions of python on your Ubuntu 20. If you overwrite your default python you are likely to encounter several other issues that may cause you to reinstall your OS, so please go through the complete post and try to make alternate installation.

In this post, I am going to write about a way to install specific python version (python 3.7.5) in your Ubuntu 20 system which initially has Python 3.8. Since, the project I have done till now had the Python version of 3.6 and 3.7. But, after I updated my OS to Ubuntu 20, my virtual environment could not be set upped as per the project requirements.

Because I wanted my old projects to be compatible, first, I thought of way to override my python 3.8 with python 3.7 but had so many other issues.

Now, I have found a way to deal with this version issue, which I will be explaining below.

1 Checking, Initial version of Python that comes with Ubuntu 20

$ python3 --version
Python 3.8.2

2 Installation of pip

a. First updating the packages

$ sudo apt update

b. Installation of pip

# The command below will install all the dependencies required for building Python modules.
$ sudo apt install python3-pip

c. Verification of pip installed

$ pip3 --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

3 Install virtualenv in your local system

Virtualenv is where all the packages required for project will be kept without dealing with local system packages.

$ pip3 install virtualenv

If you want to use Python 3.8 in your project, then, below process can be followed.

# my_project is the project directory
$ mkdir my_project && cd my_project

# Create a virtual environment in your project directory
$ python3 -m virtualenv .venv

# Activating the environment
$ source .venv/bin/activate
$ python --version
Python 3.8.2

But, this isn't our objective, we want to use other python version (Lets say Python 3.7.5). So, for that please see the below steps.

First install specific version of python in your local system without causing conflict in local system

# Update and Upgrades of packages
$ sudo apt update  
$ sudo apt upgrade -y

# Next, install the build tools and Python 3.7 dependencies using the following command:
$ sudo apt install build-essential libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev tk-dev libffi-dev

# Next, download the source code of Python 3.7 using the wget tool:
$ cd /tmp
$ wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tar.xz

# Next, decompress the tar file using:
$ tar xf Python-3.7.5.tar.xz

# Next, navigate inside your decompressed Python-3.7.0 folder:
$ cd Python-3.7.5

# Build Python 3.7.5 code using the configure and make tools:
$ ./configure --enable-optimizations
$ sudo make -j 8

# Next, run the following command to install the Python 3.7.5:
# Prefer "altinstall" than "install" because install will override the current OS python, and will cause other conflicts in OS.
$ sudo make altinstall


# Python 3.7.5 can run using:
$ python3.7 

After the specific version of python is installed successfully.

Create virtual environment in your project with specific version installed

# First know your specific python version installed path
$ which python3.7
/usr/local/bin/python3.7

# my_project is a project directory
$ mkdir my_project && cd my_project

# Create virtualenv with the specific python version path
$ python3 -m virtualenv --python=/usr/local/bin/python3.7 .venv

# Activating the virtualenv 
$ source .venv/bin/activate

# Test the python path and version
$ which python
my_project/.venv/bin/python

# python --version
Python 3.7.5

Now can work on any project as required.

Would like to get recommendation on this process, or any other ways it can be dealt with.

🌐
GitHub
gist.github.com › christian-korneck › e35bc00e12026e13f50c83519a32470e
python3.7-go-ubuntu20.04-arm64 · GitHub
# we're on Ubuntu 20.04 on arm64 $ uname -a ... Linux [...] 5.15.0 #40~20.04.1-Ubuntu [...] aarch64 [...] ... # install build tools $ apt-get -y update && apt-get -y install curl build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev pkg-config # install latest Go $ curl -L https://golang.org/dl/go1.20.4.linux-arm64.tar.gz -o go.tar.gz && tar -C /usr/local -xzf go.tar.gz && ln -s /usr/local/go/bin/go /usr/local/bin/go # build and install Python 3.7 to /opt/py $ curl https://www.python.org/ftp/python/3.7.10/Python-3.7.10.tgz -o python.tgz && tar xf python.tgz $ cd Python-3.7.10 $ ./configure --enable-shared --prefix=/opt/py $ make -j `nproc` $ make install $ echo /opt/py/lib > /etc/ld.so.conf.d/py.conf && ldconfig $ /opt/py/bin/python3.7 -m ensurepip $ export PATH=$PATH:/opt/py/bin # to persist, put this i.e.
🌐
Lunar Tips
ftp.bills.com.au › home › news › install python on ubuntu 20.04 easily
Install Python On Ubuntu 20.04 Easily
January 6, 2026 - While Ubuntu 20.04 (Focal Fossa) ... your own installation or ensure you have the latest and greatest. Firstly, version control is king. Developers often need specific Python versions for different projects. Maybe a new library you want to use requires Python 3.10, or an older project you’re maintaining strictly works with Python 3.7...