"No module named 'dnf'" after upgrade to 41

Hello.
I just upgraded my rpi3b+ from f40 → f41. (Fedora minimal aarch64)

After the (seemingly successful) upgrade there are peculiarities. During boot there were initially complaints about checks of the filesystem that did not pass, but these complaints are no more.
Postgresql sometimes fails to start because it cannot bind the server’s IP, it says. Works well if I restart the process then.
More worryingly is that during boot firewalld fails to start.
If I do

$ firewall-cmd --list-all
Traceback (most recent call last):
  File "/usr/bin/firewall-cmd", line 10, in <module>
    from gi.repository import GObject
ModuleNotFoundError: No module named 'gi'

“dnf” says

Traceback (most recent call last):
  File "/usr/bin/dnf", line 56, in <module>
    from dnf.cli import main
ModuleNotFoundError: No module named 'dnf'

What can I do? (besides make sure I have backups of everything on this database and fileshare server that I want to keep)

(I didn’t install any extracurricular versions of python on this system. There were a couple of scheduled python scripts running via their python venv. They required new venvs as appears customary)

I suspect the upgrade failed.
Dnf is still the f40 version.

1 Like

Like partially failed?
It seems to think that it’s 41:

Fedora release 41 (Forty One)
NAME="Fedora Linux"
VERSION="41 (Forty One)"
RELEASE_TYPE=stable
ID=fedora
VERSION_ID=41
VERSION_CODENAME=""
PLATFORM_ID="platform:f41"
PRETTY_NAME="Fedora Linux 41 (Forty One)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:41"
DEFAULT_HOSTNAME="fedora"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f41/system-administrators-guide/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=41
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=41
SUPPORT_END=2025-05-13
Fedora release 41 (Forty One)
Fedora release 41 (Forty One)

I had to do sudo touch /usr/lib/clock-epoch for the upgrade process to start (due to the lack of a realtime clock in this pi’s hw, I learnt this from this forum previously), and that seemed to do the trick, just like last time.

Python is 3.13 (which it should be).

1 Like

What does this output ls -l /usr/bin/dnf*?

post

python -m site
lrwxrwxrwx. 1 root root       5 Aug 15 02:00 /usr/bin/dnf -> dnf-3
-rwxr-xr-x. 1 root root    1981 Aug 15 02:00 /usr/bin/dnf-3
lrwxrwxrwx. 1 root root       5 Aug 15 02:00 /usr/bin/dnf4 -> dnf-3
-rwxr-xr-x. 1 root root 1668688 Aug  2 02:00 /usr/bin/dnf5

and

sys.path = [
    '/home/humidity',
    '/usr/lib64/python313.zip',
    '/usr/lib64/python3.13',
    '/usr/lib64/python3.13/lib-dynload',
    '/usr/lib64/python3.13/site-packages',
    '/usr/lib/python3.13/site-packages',
]
USER_BASE: '/home/humidity/.local' (exists)
USER_SITE: '/home/humidity/.local/lib/python3.13/site-packages' (doesn't exist)
ENABLE_USER_SITE: True

resp.

As far as DNF is concerned you are on a f40 system.

This is the dnf* info from my f41:

$ ls -l /usr/bin/dnf*
lrwxrwxrwx. 1 root root       4 Sep 20 01:00 /usr/bin/dnf -> dnf5*
-rwxr-xr-x. 1 root root    1986 Aug 19 01:00 /usr/bin/dnf-3*
lrwxrwxrwx. 1 root root       5 Aug 19 01:00 /usr/bin/dnf4 -> dnf-3*
-rwxr-xr-x. 1 root root 1474560 Sep 20 01:00 /usr/bin/dnf5*

With that evidence I am sure that your upgrade failed.

Check the logs of the system-upgrade:

dnf system-upgrade log
# take the number from the above and...
dnf system-upgrade log --number=<N>

Thanks for the verification then.
dnf system-upgrade log doesn’t work since dnf doesn’t.
Time to abandon ship I think.

Doh! Of course. Sorry for not realising!

Added dnf, dnf-system-upgrade, f40, upgrades