DNF gives "cannot execute: required file not found" error

when I check for dnf version
dnf --version
it shows output like this
bash: /usr/bin/dnf: cannot execute: required file not found

You can check for the presence of the DNF binary by executing the command ls /usr/bin/dnf . If the binary is there, you should see /usr/bin/dnf as output.

1 Like

If /usr/bin/dnf does not exist on your fedora system then something critical has been altered and there may be many more issues to come.

What version of fedora is installed?

A bit of history might help us understand the problem. Is this a fresh install or upgrade from previous Fedora version? Have you removed some python packages?

You should compare what your system has with the following (Fedora 38, note % the zsh prompt character, bash will show $):

% file /usr/bin/dnf
/usr/bin/dnf: symbolic link to dnf-3
% file /usr/bin/dnf-3
/usr/bin/dnf-3: Python script, ASCII text executable
% head -1 /usr/bin/dnf-3
% file /usr/bin/python3
/usr/bin/python3: symbolic link to python3.11
% file /usr/bin/python3.11
/usr/bin/python3.11: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=1b58c7fab16206dd95b1b07d5082686722d2028e, for GNU/Linux 3.2.0, stripped

This message from bash often occurs with user shell scripts that were edited in a way that adds a <CR> (DOS format) to the end of each line.