Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 3.7 on Ubuntu 20.04

I am preparing a docker image for Ubuntu 20.04 and due to TensorFlow 2.0 requirement, I need Python 3.7. TensorFlow runs on Python 3.5 to 3.7. Running apt install python3 installs Python 3.8 by default and that breaks my TensorFlow installation.

Is there any way I can get an apt package for Python 3.7 for Ubuntu 20.04? Since it is going to be inside docker image, I don't want to get into the business of downloading Python 3.7 source code and compiling. Putting those commands in Dockerfile will be overwhelming for me. Is there any simpler way of getting Python 3.7 for Ubuntu 20.04?

Running

sudo apt-cache madison python3

returns

python3 | 3.8.2-0ubuntu2 | http://in.archive.ubuntu.com/ubuntu focal/main amd64 Packages
like image 659
Kunal Shah Avatar asked Apr 25 '20 17:04

Kunal Shah


People also ask

How do I install Python 3.7 on Ubuntu?

Finally, as the required PPA is added into our Ubuntu 18.04 machine, we can now simply use apt command to install Python 3.7. The -y option in apt informs command to set automatic yes to prompts. Output $ sudo apt install python3.

What version of Python does Ubuntu 20.04 use?

We now have two versions of Python installed on our machine: the system default Python 3.8. 5, and our newly added Python 3.9. 2. We want to leave our system default Python installation alone, but we want to run our apps written in Python 3.9... so how do we manage this?


2 Answers

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.)

like image 132
wjandrea Avatar answered Oct 16 '22 15:10

wjandrea


Tensorflow 2.2 now supports python 3.8 so problem is solved now.

like image 26
Kunal Shah Avatar answered Oct 16 '22 16:10

Kunal Shah