E: Package 'python' has no installation candidate on Ubuntu 24.04 means there is no package called python to install. Install python3, and add python-is-python3 if you want the plain python command.

apt-get prints the replacement itself, a few lines above the error: 2to3 python-is-python3. In the test, apt-get install -y python3 python-is-python3 finished with exit code 0 and python --version answered Python 3.12.3.

The error

apt-get install -y python
Reading package lists...
Building dependency tree...
Reading state information...
Package python is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  2to3 python-is-python3

E: Package 'python' has no installation candidate
exit code: 100

Why it happens

The package lists know the name python, because another package refers to it, but no version of it exists in the enabled sources. apt-cache policy shows that directly:

apt-cache policy python
python:
  Installed: (none)
  Candidate: (none)
  Version table:

Candidate: (none) with an empty version table is the whole story: there is nothing apt-get could choose. apt-get knows the name and even suggests what replaced it, so a tutorial or setup script that says sudo apt-get install python stops here on Ubuntu 24.04 with exit code 100.

The fix

apt-get install -y python3 python-is-python3 > /tmp/py.log 2>&1
exit code: 0
tail -2 /tmp/py.log
running python post-rtupdate hooks for python3.12...
Setting up python-is-python3 (3.11.4-1) ...
python --version
Python 3.12.3

python3 is the interpreter. python-is-python3 is the small package from the error's own suggestion list; once it was installed, the bare python command ran Python 3.12.3. If your scripts already call python3, the first package is enough. The other name in the list, 2to3, was not installed in this test.

The commands ran as root in the container; in your WSL terminal put sudo in front of apt-get. When you meet the same message for another package, read the lines above the E: line first, and run apt-cache policy with the package name to see whether any candidate exists.

How it was reproduced

The capture was made in an ubuntu:24.04 container (Ubuntu 24.04.5 LTS, apt 2.8.3, Docker Engine 29.9.2) standing in for Ubuntu in WSL, after an apt-get update against the default sources of the image. The script ran apt-get install -y python, which failed with exit code 100, then apt-cache policy python, then installed python3 and python-is-python3 (output saved to a log, last two lines shown) and checked python --version.

Frequently asked

How do I install python on Ubuntu 24.04 when apt says no installation candidate?
Install python3 instead, and python-is-python3 if you want the plain python command. In the test apt-get install -y python3 python-is-python3 returned exit code 0 and python --version printed Python 3.12.3.
What does has no installation candidate mean in apt-get?
apt-get knows the package name but has no version of it to install from the enabled sources. apt-cache policy python showed Candidate: (none) and an empty version table.
What is python-is-python3 on Ubuntu?
It is one of the replacements apt-get listed for the python package. After installing it in the test, the python command ran Python 3.12.3.

More decoded errors in the Fixes category. For the related apt-get message in a Dockerfile, see E: Unable to locate package.