60

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
1
  • hye, if you look into dockerhub , you can find the official images of tensorflow, you can find tensorflow in any version running on almost any python version too! Commented Jan 29, 2022 at 20:47

2 Answers 2

117

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

5
  • 1
    I am not sure if I will be adding PPA. But thanks though. It looks like temporary fix. I was expecting more of a permanent fix.
    – Kunal Shah
    Commented Apr 25, 2020 at 18:43
  • 2
    @Kunal I don't think Python 3.7 or below will ever be officially packaged for Ubuntu 20.04. Seems like the Ubuntu devs never package older minor versions.
    – wjandrea
    Commented Apr 25, 2020 at 18:47
  • 1
    so in that case, I will have to wait till tensorflow certifies python3.8 to be used on 20.04. Till then, it is TF 2.x on 18.04
    – Kunal Shah
    Commented Apr 25, 2020 at 18:56
  • @Apurva What error are you getting? I just updated from it and checked the website and it's fine.
    – wjandrea
    Commented Oct 25, 2023 at 14:33
  • 1
    @Apurva Sounds like an organizational setting is blocking it. Check out this question on Ask Ubuntu: Cannot add PPA - "user or team does not exist". BTW, make sure to always provide verbatim error messages; this one seems to be "... user or team does not exist".
    – wjandrea
    Commented Oct 26, 2023 at 15:52
9

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

3
  • 2
    But not TF.lite yet :-( Commented Aug 6, 2020 at 5:26
  • 2
    But not for Raspberry Pi (aarch64) in case anyone is wondering...
    – pookie
    Commented Nov 13, 2020 at 22:08
  • Just needed an aditionnal year and TFlite 2.5 to solve it... Commented Jul 1, 2021 at 12:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.