Ask Your Question

Removed global pip dependencies broke dnf

asked 2018-01-02 10:01:44 -0500

Morishiri gravatar image

updated 2018-01-03 02:08:23 -0500


I was cleaning up some things on my Fedora Workstation 27 and I executed sudo pip3 freeze | sudo pip3 uninstall -y (and the same thing with pip for Python2) which removed all dependencies.

I was not aware that dnf depends on it and I thought that all this packages was recently installed by me.

Now, while running dnf I get the following output:

Traceback (most recent call last):
  File "/bin/dnf", line 57, in <module>
    from dnf.cli import main
  File "/usr/lib/python3.6/site-packages/dnf/", line 31, in <module>
    import dnf.base
  File "/usr/lib/python3.6/site-packages/dnf/", line 37, in <module>
    import dnf.conf
  File "/usr/lib/python3.6/site-packages/dnf/conf/", line 40, in <module>
  File "/usr/lib/python3.6/site-packages/dnf/conf/", line 26, in <module>
    from iniparse.compat import ParsingError, RawConfigParser as ConfigParser
  File "/usr/local/lib/python3.6/site-packages/iniparse/", line 6, in <module>
    from ini import INIConfig, change_comment_syntax
ModuleNotFoundError: No module named 'ini'

I tried pip3 install ini but it looks like it is not this package, as this is trying to install something written for python2 I guess.

rpm -Va also contains a lot of missing packages, but when I tried to reinstall them via rpm, and it's a lot so installing them manually is a horror due to growing dependency tree. Also some of them seems to not be available on the Internet.

Is there some way to fix dnf or restore it to previous stage?

I found a solution involving yum-deprecated, but it's not available anymore on Fedora 27 and installing it with rpm takes a lot of effort due to dependency tree.

If any information is needed please let me know, I will deliver it right away.

--- EDIT --- Information added ---

I put this downlaoded packages in proper directories manually. Anyway the problem still exist.

Looks like the iniparse mdoule has troubles with file.

iniparse directory (pwd: /usr/lib/python3.6/site-packages/iniparse has the following files in it:     __pycache__

and in __pycache__:

compat.cpython-36.opt-1.pyc        ini.cpython-36.opt-1.pyc
compat.cpython-36.pyc              ini.cpython-36.pyc
config.cpython-36.opt-1.pyc        __init__.cpython-36.opt-1.pyc
config.cpython-36.pyc              __init__.cpython-36.pyc
configparser.cpython-36.opt-1.pyc  utils.cpython-36.opt-1.pyc
configparser.cpython-36.pyc        utils.cpython-36.pyc

The sixth line in iniparse's contains:

from .ini import INIConfig, change_comment_syntax

so it should be resolved, but it yields that the ini module doesn't exist. What can be the problem here? Maybe something with pyc files?

edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted

answered 2018-01-05 05:14:26 -0500

FranciscoD_ gravatar image

I reckon the simplest way here would be to do a fresh install. I hope you have a separate /home partition which would make things a lot easier. Extracting rpms and placing files in paths and all of that is mind numbingly tedious, and even if you do do it all correctly, there may be missing bits later.

As a rule, do not mix dnf packages and other package managers such as pip. Always use a virtual environment with pip and limit this to the local user only. There is almost no use case where you'd want to run pip with sudo priviliges to install these packages system wide.

edit flag offensive delete link more



Another note: your python paths are also broken because you used pip globally. Fedora packages DO NOT install anything into /usr/local/.

FranciscoD_ gravatar imageFranciscoD_ ( 2018-01-05 05:16:01 -0500 )edit

Well spotted,

   File `/usr/local/lib/python3.6/site-packages/iniparse/`, line 6, in <module>
        from ini import INIConfig, change_comment_syntax

Removing /usr/local/lib/python3.6/site-packages/ might fix things. If pip installes things into /usr/local, then the python path should also include /usr/local/lib/python3.6/site-packages

villykruse gravatar imagevillykruse ( 2018-01-05 10:59:35 -0500 )edit

I removed /usr/local then dnf started complainign about missing six module. I installed that and everything started to work! Thank you very much!

Morishiri gravatar imageMorishiri ( 2018-01-06 07:14:03 -0500 )edit

Yeh, but unfortunately, that does not imply that the system has been fixed. You may run into issues in the future again because of missing files or mangled paths. You should use some of the commands listed in other comments to verify that all the files from the pacakges installed on your system are still present: rpm -Va... etc.

FranciscoD_ gravatar imageFranciscoD_ ( 2018-01-07 07:27:21 -0500 )edit

I fixed other missing packages etc by using dnf (by reinstalling every package missing in rpm-Va) so my system is fine right now in my opinion

Morishiri gravatar imageMorishiri ( 2018-01-09 15:49:45 -0500 )edit

answered 2018-01-02 13:01:20 -0500

davidva gravatar image

updated 2018-01-02 13:21:51 -0500

mmm bad bad bad; play with pip in mode root bad idea... you need install python2-pip and python3-pip and python3 with your hand... extracting, copying and paste in the correct paths... you can download the rpms from here:












Next you can reinstall again...

dnf -y reinstall python2-pip python3-pip python2 python3

dnf -y distro-sync
edit flag offensive delete link more



sudo rpm -Va 'python*'

can tell you if you have other python packages that needs to be fixed.

You can fix all of them by re-installing all python packages if you don't mind downloading stuff you might not need.

sudo dnf reinstall 'python*'
villykruse gravatar imagevillykruse ( 2018-01-02 14:59:04 -0500 )edit

I tried installing that packages with sudo rpm -i --force. It didn't help then. I will try to install them by copying paths as you said, thanks for the advice. I will let you know about the result.

Answering comment above: sudo rpm -Va 'python*' yelds 6532 lines, some of them are marked as missing and some replaced.

About the sudo dnf reinstall 'python*' - I can't execute it, because I'm getting the stack trace which I put in question content.

Morishiri gravatar imageMorishiri ( 2018-01-02 15:29:35 -0500 )edit

sudo rpm -Va 'python*' after installing the downloaded rpms as given in the answer. Each of the lines in the result has a file name you can give as parameter to rpm -qr. That would give one of the rpm pacakge names that eventually needs to be re-installed.

villykruse gravatar imagevillykruse ( 2018-01-02 23:30:07 -0500 )edit

I put this downlaoded packages in proper directories manually. Anyway the problem still exist. It looks like there is something wrong with iniparse module. I added more information in the question.

Morishiri gravatar imageMorishiri ( 2018-01-03 02:09:02 -0500 )edit

You need play with the dependencies... if you believe parse is the problem; then we need a dependency:


davidva gravatar imagedavidva ( 2018-01-03 17:18:00 -0500 )edit

answered 2018-05-23 11:06:43 -0500

dnf is likely broken on your system. Modern fedora uses python3, so you might use the following script to reinstall all python3 packages against a fedora mirror (worked for me on a fedora 28 test box):

echo "Reinstalling all python3 packages via rpm"
rpm -qa | grep python3 > $PACKAGES_FILE
echo "Placed all python3 packages in $PACKAGES_FILE"
for PACKAGE in $(cat $PACKAGES_FILE); do
    echo "Grabbing $PACKAGE rpm"
    wget "$ROOT_MIRROR_URL/$PACKAGE.rpm"
    echo "Installing $PACKAGE rpm"
    rpm -Uvh --force $PACKAGE.rpm
echo "Done!"
rm $PACKAGES_FILE python3*.rpm
edit flag offensive delete link more

answered 2018-01-02 16:19:02 -0500

MaoTao gravatar image

updated 2018-01-02 16:19:40 -0500

I would try to revert to a previous state as a first step:

sudo dnf history list and after sudo dnf history rollback <transaction ID> or sudo dnf history undo <transaction ID>

If those don't help, i would consider using a live media system (DVD drive or USB) with which you could repair by installing the required binaries, in order to make your system work again.

edit flag offensive delete link more


Unfortunatelly the problem is that I can't run dnf command at all.

Morishiri gravatar imageMorishiri ( 2018-01-03 02:09:30 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-01-02 10:00:27 -0500

Seen: 1,214 times

Last updated: Jan 05 '18