Skip to content Skip to sidebar Skip to footer

Dnf And Yum Does Not Work After Purging Usr/lib/python3.5/site-packages/

I was fiddling around with Fedora, trying to uninstall a python Module. I couldn't find the one that I was looking for , so the half linux-primate brain thought of an Idea , to exe

Solution 1:

Purging the Site-Packages directory of Python3 removes a lot of the libraries that Fedora needs to function properly. This means tools like dnf and yum does not work.

These are the Steps that I took to fix this.

Step 1: Install yum-deprecated. Just type yum-deprecated on the terminal and it will ask do you want to install it. Type y and it will be installed.

Step 2: Run this Bash Command

rpm -qa | egrep "^python3" | sed ':a;N;$!ba;s/\n/ /g' | xargs sudo yum-deprecated reinstall -y

This finds all the names of the Installed python 3 packages , and reinstall them.

Note to Myself: Never run commands like sudo rm -rf /usr/lib/python3.5/site-packages/ ever again.

Solution 2:

Use 'rpm -Va' to identify the packages with missing files. You'll then have to download the matching RPM files from a Fedora mirror, and then use rpm --reinstall to fix those.

The higher-level dnf and yum packages rely on Python, so they're likely to just be broken. Fortunately, the lower-level rpm command doesn't, so if python packages are all you've removed, this should get you back in shape.

Solution 3:

You basically removed a lot of python files. A large portion of the system depends on the python, including dnf itself, which is written in python.

The best thing to do would be to back up all your files and reinstall system. If yum-deprecated still works, you might have the luck with reinstalling dnf:

yum-deprecated reinstall "dnf*"

but most probably you will need much more packages to take through the same procedure.

Solution 4:

This can help.

yum update python*

yum install dnf-data dnf-plugins-core libdnf-devel libdnf python2-dnf-plugin-migrate dnf-automatic

Solution 5:

I have a friend who meet the same problem.

He tries to uninstall python3.7 in linux server by some amazing cmd rpm -qa|grep python3|xargs rpm -ev --allmatches --nodeps and whereis python3 |xargs rm -frv. This cause the yum and dnf broken.

Because we can not find yum-deprecated,so there are the following attempt.

I change the /usr/bin/yum to use a local python3.8 version, but it cause ModuleNotFoundError: No module named 'dnf' at last, and not solved it.

It is not a good way to download many rpm packages in internet. And I can't use yum either. But I have another same os linux server, so I tried to copy the correlation files about python3.7.

$ rpm -ql python3-3.7.0-9.h4.eulerosv2r8.aarch64> py.log
$ whileread -r line;dodirname$line |xargs -I {} ssh root@$remoteip"mkdir -p {}" ;scp $line root@$remoteip:$line  ;done<py.log

$ rpm -ql python3-libs-3.7.0-9.h4.eulerosv2r8.aarch64 >pylib.log
$ whileread -r line;dodirname$line |xargs -I {} ssh root@$remoteip"mkdir -p {}" ;scp $line root@$remoteip:$line  ;done<pylib.log

scp -r /usr/lib/python3.7/site-packages root@$remoteip:/usr/lib/python3.7/

I recover yum by this way.

Post a Comment for "Dnf And Yum Does Not Work After Purging Usr/lib/python3.5/site-packages/"