Score:0

Ubuntu 22 package management broken

za flag

Package management seems to have gotten into a mess. apt upgrade gives me:

Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies.
 libpython3-stdlib : Depends: libpython3.10-stdlib (>= 3.10.6-1~) but it is not installed
 python3.10 : Depends: libpython3.10-stdlib (= 3.10.11-1+focal1) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

But then if I run apt --fix-broken install:

Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following packages will be REMOVED
  libpython3-stdlib python3 python3-apt python3-pkg-resources python3-yaml python3.10 ubuntu-advantage-tools
0 to upgrade, 0 to newly install, 7 to remove and 1 not to upgrade.
After this operation, 3,546 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 271677 files and directories currently installed.)
Removing ubuntu-advantage-tools (27.14.4~22.04) ...
Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/usr/lib/python3/dist-packages/uaclient/apt.py", line 14, in <module>
    import apt  # type: ignore
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 26, in <module>
    from apt.package import Package as Package, Version as Version
  File "/usr/lib/python3/dist-packages/apt/package.py", line 32, in <module>
    from http.client import BadStatusLine
ModuleNotFoundError: No module named 'http'
dpkg: error processing package ubuntu-advantage-tools (--remove):
 installed ubuntu-advantage-tools package pre-removal script subprocess returned error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
 ubuntu-advantage-tools
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)

I'm guessing python is completely borked, but I don't know how to begin fixing it when apt is also borked. sudo apt clean hasn't helped, but I'm way beyond that...

Any suggestions greatly appreciated!

user535733 avatar
cn flag
This like a classic self-inflicted version conflict. It would help a lot to know the last package actions that worked, as that's what likely caused the problem. See /var/log/apt to refresh your memory, if needed. `apt clean` may have been unwise; it deleted the older packages that you may need to reinstall.
Dan12345 avatar
za flag
I think I've solved it by manually downloading the debs for python 3.10 (and the dependencies) and installing them. Python then works. I then deleted all python packages (not needed, as apps are all in venvs) and touch wood things are now working.
guiverc avatar
cn flag
That looks like a 22.04 or 22.10 system, and not 22 (*Ubuntu uses the year format for snap only products, like Ubuntu Core 22 - these don't use* `apt`). Your packages don't look correct for either 22.04 or 22.10 though ! being `libpython3.10-stdlib | 3.10.6-1~22.04.2ubuntu1 | jammy-updates | amd64, arm64, armhf, i386, ppc64el, riscv64, s390x` or `libpython3.10-stdlib | 3.10.7-1ubuntu0.3 | kinetic-updates | amd64, arm64, armhf, i386, ppc64el, riscv64, s390x`
Dan12345 avatar
za flag
You're right - it was 22.04. The problem turned out to be a python repo from "deadsnakes" that I'd added, and had resulted in some python packages being updated but others not. I don't know why. Replaced everything with the standard 22.04 packages and seems fine now.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.