2

I've recently upgraded from 20.04 to 21.04. The problem is that I have many python virtualenvs that use python 3.8 which is not installed by default.

How can I fix the virtualenvs so it works again?

sudo add-apt-repository ppa:deadsnakes/ppa

is telling me that:

Reading package lists... Done           
E: The repository 'http://ppa.launchpad.net/deadsnakes/ppa/ubuntu hirsute Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

And sudo apt-get update --allow-insecure-repositories:

Reading package lists... Done
W: The repository 'http://ppa.launchpad.net/deadsnakes/ppa/ubuntu hirsute Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch http://ppa.launchpad.net/deadsnakes/ppa/ubuntu/dists/hirsute/main/binary-i386/Packages  404  Not Found [IP: 91.189.95.85 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.

EDIT:

So I'm trying to install the 3.8 from the source. I've downloaded python 3.8.9.tgz and now I'm going to install it - will it corrupt the latest version?

Milano
  • 613

1 Answers1

3

This is totally unsupported, but for most interim releases, you can get away with installing packages from a previous release. This is never guaranteed to work. For example, previously, I was able to edit the sources.list.d entry for Groovy to refer to Focal, and everything worked fine.

For Hirsute, since the system python is python3.9, you need to be extra careful not to replace that package. You also need to go through some extra steps with package pinning to avoid it. Also, the Focal repo won't provide python3.8, so you need another repo and pin rule to bring that in from Bionic. Here's the setup, which I wrote up in more detail here.

/etc/apt/sources.list.d/deadsnakes.list:

deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu/ focal main
deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu/ bionic main

/etc/apt/preferences.d/deadsnakes:

Explanation: Prevent installing from deadsnakes repo.
Package: *
Pin: release o=LP-PPA-deadsnakes
Pin-Priority: 1

Explanation: Allow installing python 3.{6,7} from deadsnakes/focal Package: python3.6 python3.7 Pin: release o=LP-PPA-deadsnakes,n=focal Pin-Priority: 500

Explanation: Allow installing python 3.8 from deadsnakes/bionic Package: python3.8 Pin: release o=LP-PPA-deadsnakes,n=bionic Pin-Priority: 500

Be sure to run sudo apt update to refresh repository metadata, and then you should be able to install alternative Python package versions.

Note that if you go this route, you're signing up to make sure you audit all of your repos and pinning rules after each release upgrade, since they'll generally get disabled. You're also signing up to maybe have some debugging from messing things up. Please don't bother the deadsnakes repository maintainers with issues you encounter from doing this. They do not support non-LTS releases.

brenns10
  • 131
  • Installing python3.8 requires libpython3.8-sdtlib which it need libffi6, libmpdec2 and libreadline7. I guess I need to add bionic as a repo? In that case, should I pin other pacakges? – zunbeltz Jul 02 '21 at 08:04
  • I answer my own comment. Just need to add bionic main source. No need to pin packages. – zunbeltz Jul 02 '21 at 09:29