I'm on Ubuntu 18.04; I expect pip to be installed for python3.8 when I do the following:

apt update
apt install python3.8
ln -sf /usr/bin/python3.8 /usr/bin/python3
ln -sf /usr/bin/python3 /usr/bin/python

apt update
apt install python3-pip

However when install python3-pip it additionally installs python3.6, python3.6-dev, python3.6-minimal, Are these really required? I intend to use them in containerized environments and hence keeping the image size to real minimum becomes necessary. What is the right way to get python3.8 + pip with bare essential requirements only?

Edit: I'm aware I could build on top of python:3.8 containers from docker-hub, but this question applies say I need to build on top of other containers such as cuda.

Update: With Ubuntu 16.04 or older, we need to add deadsnakes PPA to sources and it requires apt-add-repository which in turn requires python. So when I install software-properties-common I end up

  1. installing python3.5
  2. install apt-add-repository
  3. add deadsnakes PPA
  4. apt update
  5. and finally install python3.8 -- which may be okay when I'm setting up my desktop with linux, but seems to me like a lot of stuff for containers.
  • It could be because it's listed as a peer dependency in the official PPA, don't worry though, it doesn't take a lot of disk space anyways – Mattia Oct 15 '20 at 8:52

Ubuntu major releases pin the "major" versions of their packages to what was new at the time of release in order to provide a stable platform. For instance, it would be bad if a Python program written on 18.04.0 suddenly stopped working in 18.04.5 because Python was bumped from 3.6 to 3.8.

If you cannot use the official Python images, need Python 3.8, and cannot use Focal/20.04 (which ships with Python 3.8), the deadsnakes PPA is really your only option. You don't need the apt-add-repository command as you can just add the source directly and add the GPG manually. If you click on the "Technical details about this PPA" link on the PPA homepage, it gives you the relevant sources.list/sources.list.d entry as well as the GPG key ID you need to add the repo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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