3

I am trying to install Python 3.9, but Debian comes with 3.7.

When I run sudo apt install python3.9, I receive this:

E: Unable to locate package python3.9
E: Couldn't find any package by glob 'python3.9'
E: Couldn't find any package by regex 'python3.9'

When I run sudo apt install python3, I get this:

python3 is already the newest version (3.7.3-1).

I've manually went and found that there is in fact Python 3.9 on Debian's servers. It's located here.

I then downloaded the deb file for Python 3.9 and ran sudo apt install ./python3.9*, I resulted in this:

Note, selecting 'python3.9' instead of './python3.9_3.9.6-1_i386.deb'
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 python3.9 : Depends: python3.9-minimal (= 3.9.6-1) but it is not installable
             Depends: libpython3.9-stdlib (= 3.9.6-1) but it is not installable
E: Unable to correct problems, you have held broken packages.

I then downloaded the deb files for these two and tried the same thing, but it ended up with more dependencies that are 'not installable'.

I know that you cannot install packages that are not configured for the version of Debian I am running, but is there a way to install Python 3.9? Is there a way to install it without building it from source?

I am running Debian 10.10 (buster) with the i386 (32-bit) architecture.

My sources.list (I am using the Australian mirror):

deb http://ftp.au.debian.org/debian/ buster main
deb-src http://ftp.au.debian.org/debian/ buster main

deb http://ftp.au.debian.org/debian/ buster/updates main
deb-src http://ftp.au.debian.org/debian/ buster/updates main

# buster-updates, previously known as 'volatile'
# deb http://ftp.au.debian.org/debian/ buster-updates main
# deb-src http://ftp.au.debian.org/debian/ buster-updates main

2 Answers 2

10

You can see from Debian's tracker that:

  • Debian 9 (stretch/oldstable) shipped with 3.5.3
  • Debian 10 (buster/stable) ships with 3.7.3
  • Debian 11 (bullseye/testing) will ship with 3.9.2
  • experimental has 3.9.4
  • python3 is not available in stable-backports

bullseye will release in a few weeks. If you do a dist-upgrade to bullseye, you'll get python3.9. That's the safest thing you can do.

It's possible to add experimental to your souces.list, and then sudo apt install -t experimental python3, but you are replacing a very core package and that has some dangerous potential if things don't go perfectly.

Also note: If you are on Debian 10, all native packages will work with python3.7. There is very little reason to upgrade unless you are writing python code yourself and you are specifically trying to use the features provided by the newer version. If you are relying on pip packages, most of those are available as python3-<pkg> for python3.7 in debian 10.

1
  • 3
    Re. experimental, experimental packages work with unstable, so it’s generally not a good idea to mix them with testing or stable (unless one knows enough to figure things out on one’s own). For development, virtualenvs allow any version of Python to be used. Jul 14, 2021 at 11:13
1

Replacing the system python with a non-standard version is an extremely bad idea and has a high chance of breaking your system. It would be better to either upgrade the whole system to get the newer python or install a separate python in another directory.

If you really need a different version of python, instead of replacing the system python, you should consider installing something like anaconda in your home directory.

However, this then brings up the problem of multiple python versions available, and you need to be careful you are always running the python you expect.

1
  • You're right. Until bullseye comes out, I've build Python from source.
    – Maytha8
    Jul 30, 2021 at 9:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .