Installation of Python 3.10 broke dnf and yum

After downloading python 3.10 and being stupid by trying to set the version of the Python of my machine to Python 3.10 I broke both dnf and yum. I realized now I should of used a vritual environment instead. My machine is currently based in Fedora 34 workstation edition. Here is the error message every time I type yum or dnf in the command line:

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

Thanks

Do you remember what steps you followed, and what system files they may have overwritten? (We need to undo them to fix your system Python installation)

I believe it was this tutorial:
https://linuxconfig.org/how-to-switch-between-python-versions-on-fedora-linux. The files that I having issues with are:

File "/usr/bin/yum", line 57, in <module>
    from dnf.cli import main

File "/usr/bin/dnf", line 57, in <module>
    from dnf.cli import main
1 Like

At the moment, the dnf python package cannot be found. This can be for a number of reasons—from the files having being deleted to your default python version having been changed.

Sure, but did you follow all of that or specific bits? What versions of Python did you tweak? Did you use the “alternatives”? Did you install more packages using pip after you made your changes?

Basically the more information we have over what was done, the more chances we have of undoing it.

For example, can you go over your shell history to see what commands you ran? history in a terminal? Can we also have the output of python --version, and the output of fpaste --printonly --sysinfo please?

1 Like

Good news is: When you reinstall your machine and you use F35 (or you manage to recover and upgrade from the soon-to-be EOL F34 to F35), python 3.10 is part of it.

Next time you mess around with Python versions, use virtual environments, for example: Managing environments — conda dev documentation

Yea, l learned the hard way. I’ve upgraded my machine before and I have my home folder on a partition so installation should not cause any problems. For the virtual environment I am going with poetry and pyenv. I have been using both for some time and they get the job done perfectly.

1 Like