E: You don't have enough free space in /var/cache/apt/archives/. means the packages apt wants to download do not fit in the folder where it stores them. Check the room with df -h /var/cache/apt/archives. In the test apt-get clean did not help because the folder was already empty; pointing apt's download folder at a filesystem with room let the install finish.

First compare the Need to get line in apt's output with the Avail column from df. If the folder holds old downloads, apt-get clean removes them; if the filesystem itself is too small, give apt another place or more room.

The error

$ df -h /var/cache/apt/archives
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           1.0M     0  1.0M   0% /var/cache/apt/archives
exit code: 0
$ apt-get install -y python3
Reading package lists...
Building dependency tree...
Reading state information...
...
1 upgraded, 16 newly installed, 0 to remove and 12 not upgraded.
Need to get 10.4 MB of archives.
After this operation, 30.2 MB of additional disk space will be used.
E: You don't have enough free space in /var/cache/apt/archives/.
exit code: 100

Why it happens

The message names /var/cache/apt/archives/, the folder apt downloads packages into. apt reported Need to get 10.4 MB of archives, the folder was a 1 MB filesystem, and apt stopped there with exit code 100. The test set this up on purpose: the container was started with --tmpfs /var/cache/apt/archives:size=1m. df -h on the folder shows which filesystem holds it and how much is free.

apt-get clean deletes downloaded package files from that folder: in a separate ordinary container, after apt-get install -y --download-only jq left three .deb files there, apt-get clean removed them and ls showed only lock and partial. Here df showed it empty (0 used), so it changed nothing:

$ apt-get clean
exit code: 0
$ apt-get install -y python3 2>&1 | tail -2
After this operation, 30.2 MB of additional disk space will be used.
E: You don't have enough free space in /var/cache/apt/archives/.
exit code: 0

(The exit code: 0 on the second command is from tail, the last command in the pipe; the error line is apt's.)

The fix

$ df -h /tmp
Filesystem      Size  Used Avail Use% Mounted on
overlay        1007G   40G  916G   5% /
exit code: 0
$ mkdir -p /tmp/aptarch/partial && apt-get install -y -o Dir::Cache::Archives=/tmp/aptarch/ python3 > /tmp/q7.log 2>&1; echo "install exit: $?"; tail -3 /tmp/q7.log
install exit: 0
running python rtupdate hooks for python3.12...
running python post-rtupdate hooks for python3.12...
Processing triggers for libc-bin (2.39-0ubuntu8.9) ...
exit code: 0
$ python3 --version
Python 3.12.3
exit code: 0

-o Dir::Cache::Archives=/tmp/aptarch/ told apt to download into a folder on the large filesystem for this one command, with the partial subfolder created first. The install returned 0 and Python 3.12.3 ran. That is a one-off way round a small partition; the lasting fix is to free space on the filesystem that holds /var/cache/apt/archives or to give it more, which in this container would have meant starting it with a larger tmpfs (not run here).

How it was reproduced

The capture was made in an ubuntu:24.04 container (Ubuntu 24.04.5 LTS, apt 2.8.3) on Docker Engine 29.9.3, standing in for Ubuntu in WSL, started with docker run -d --name fix10-la-g --tmpfs /var/cache/apt/archives:size=1m ubuntu:24.04 sleep infinity. As root, after apt-get update, python3 was installed three ways: plainly, after apt-get clean, and with a different archives folder.

Frequently asked

How do I fix 'You don't have enough free space in /var/cache/apt/archives'?
Compare Need to get with df -h /var/cache/apt/archives. Free space there, or run the install with -o Dir::Cache::Archives= pointing at a folder with room; in the test the second way installed python3.
Does apt-get clean fix 'not enough free space'?
Not in this test. The folder was empty to begin with, and after apt-get clean the same install failed with the same message.
How much space does apt need for an install?
The Need to get line shows the download size and the After this operation line the installed size. In the test they were 10.4 MB and 30.2 MB.

More decoded errors in the Fixes category. If a package install fails after the download instead, see Sub-process /usr/bin/dpkg returned an error code (1).