Ask Your Question

How to solve broken dnf in Fedora 26

asked 2017-09-29 09:45:49 -0500

msmafra gravatar image

updated 2017-11-13 13:07:08 -0500

My dnf stop working and showing this error:

    Traceback (most recent call last):
      File "/usr/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/lib/python3.6/site-packages/iniparse/", line 6, in <module>
        from .ini import INIConfig, change_comment_syntax
      File "/usr/lib/python3.6/site-packages/iniparse/", line 47, in <module>
        import six
    ImportError: bad magic number in 'six': b'\x03\


I really don't remmenber any thing that I installed besides Fedora's own updates via dnf distro-sync. Could it be a problem with python version change?

I use Fedora 26 Workstation x86_64

After running sudo find / -name '*' as instructed by @villykruse

/usr/bin/six.pyc /usr/lib/python2.7/site-packages/pkgresources/vendor/ /usr/lib/python2.7/site-packages/pkgresources/vendor/six.pyc /usr/lib/python2.7/site-packages/pkgresources/vendor/six.pyo /usr/lib/python2.7/site-packages/pip/vendor/requests/packages/urllib3/packages/ /usr/lib/python2.7/site-packages/pip/vendor/requests/packages/urllib3/packages/six.pyc /usr/lib/python2.7/site-packages/pip/vendor/requests/packages/urllib3/packages/six.pyo /usr/lib/python2.7/site-packages/pip/vendor/ /usr/lib/python2.7/site-packages/pip/vendor/six.pyc /usr/lib/python2.7/site-packages/pip/vendor/six.pyo /usr/lib/python2.7/site-packages/urllib3/packages/ /usr/lib/python2.7/site-packages/urllib3/packages/six.pyc /usr/lib/python2.7/site-packages/urllib3/packages/six.pyo /usr/lib/python2.7/site-packages/ /usr/lib/python2.7/site-packages/six.pyc /usr/lib/python2.7/site-packages/six.pyo /usr/lib/python3.6/site-packages/pip/vendor/requests/packages/urllib3/packages/ /usr/lib/python3.6/site-packages/pip/vendor/ /usr/lib/python3.6/site-packages/pkgresources/vendor/ /usr/lib/python3.6/site-packages/urllib3/packages/ /usr/lib/python3.6/site-packages/ /usr/lib64/python2.7/site-packages/M2Crypto/ /usr/lib64/python2.7/site-packages/M2Crypto/six.pyc /usr/lib64/python2.7/site-packages/M2Crypto/six.pyo /usr/lib64/chromium-browser/pyproto/google/thirdparty/six/ /usr/lib64/chromium-browser/pyproto/google/thirdparty/six/six.pyc /usr/lib64/chromium-browser/pyproto/google/thirdparty/six/six.pyo /usr/share/hplip/base/ /var/lib/docker/btrfs/subvolumes/30f01585d81ed8a02aacb303d5df496ba25d36b37365c7460cb5ebf94eac48c6/usr/lib/python2.7/dist-packages/ /var/lib/docker/btrfs/subvolumes/30f01585d81ed8a02aacb303d5df496ba25d36b37365c7460cb5ebf94eac48c6/usr/lib/python2.7/dist-packages/six.pyc /var/lib/docker/btrfs/subvolumes/10858e8f6977f1f1bff06da73e2c6b7a11f2cd1ad50f8db5764f94a6748a2d0b/usr/lib/python2.7/dist-packages/ /var/lib/docker/btrfs/subvolumes/10858e8f6977f1f1bff06da73e2c6b7a11f2cd1ad50f8db5764f94a6748a2d0b/usr/lib/python2.7/dist-packages/six.pyc /var/lib ...

edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted

answered 2017-09-29 16:02:35 -0500

villykruse gravatar image

See explanation

What this boils down to is that you probably is trying to import a python2 version of six.pyc .

The files should be


The start of these files should be. (xxd is provided by the vim-common package).

[root@mybox vek]# xxd /usr/lib/python3.6/site-packages/__pycache__/six.cpython-36.pyc | head -1
00000000: 330d 0d0a 3b55 5a59 9275 0000 e300 0000  3...;UZY.u......

[root@mybox vek]# xxd /usr/lib/python3.6/site-packages/__pycache__/six.cpython-36.opt-1.pyc | head -1
00000000: 330d 0d0a 3b55 5a59 9275 0000 e300 0000  3...;UZY.u......

If not, remove those two files, and then run

dnf reinstall python3-six

to reinstall these files from the repository.

If the start of the files matches what is stated above, you may have some environment variable which modifies the python search path. Or, you have a python module named six somewhere else.

edit flag offensive delete link more


I ran yum-deprecated reinstall python3-six. Even tried reinstalling dnf using yum-deprecated

msmafra gravatar imagemsmafra ( 2017-10-06 08:35:47 -0500 )edit


sudo find / -name '*'

and report the result

villykruse gravatar imagevillykruse ( 2017-10-06 10:40:08 -0500 )edit

Most likely it is the existence of the file /usr/bin/six.pyc that causes the problem. The problem is that /usr/bin is the first place where python looks for modules, and if it finds a python2 version of .pyc file without a corresponding .py file, you will get this:

ImportError: bad magic number in 'six': b'\x03\xf3\r\n'
villykruse gravatar imagevillykruse ( 2017-10-09 22:14:42 -0500 )edit

Hi. Sorry, I am not sure if I've tried your suggestion before @villykruse. Turns out that moving the /usr/bin/six.pyc to /tmp did the trick. I had already upgraded to Fedora 27 to try solving this problem. And it was that easy. Thank you very much!

msmafra gravatar imagemsmafra ( 2017-11-13 12:59:57 -0500 )edit

answered 2017-09-29 14:58:31 -0500

Phoenix_masshhad gravatar image
cd /var/lib
rm __db*
rpm --rebuilddb
edit flag offensive delete link more

answered 2017-10-09 09:43:47 -0500

msmafra gravatar image

It returned to many lines to post here. /usr/bin/six.pyc /usr/lib/python2.7/site-packages/pkgresources/vendor/ /usr/lib/python2.7/site-packages/pkgresources/vendor/six.pyc /usr/lib/python2.7/site-packages/pkgresources/vendor/six.pyo /usr/lib/python2.7/site-packages/pip/vendor/requests/packages/urllib3/packages/ /usr/lib/python2.7/site-packages/pip/vendor/requests/packages/urllib3/packages/six.pyc /usr/lib/python2.7/site-packages/pip/vendor/requests/packages/urllib3/packages/six.pyo /usr/lib/python2.7/site-packages/pip/vendor/ /usr/lib/python2.7/site-packages/pip/_ve

edit flag offensive delete link more

answered 2017-09-29 10:59:47 -0500

masteroman gravatar image

Have you messed with some python related packages as root on that system?

You could see if you have DNF package cached in /var/cache/dnf/ and then install it from there again too see if that will fix the issue. Packages you likely need to re-install are dnf and python3-dnf

You should be able to install package manually with rpm:

rpm -iv --replacepkgs /var/cache/dnf/PATH/TO/PACKAGE
edit flag offensive delete link more


dnf was not cached. I ran yum-deprecated reinstall python3-dnf. Even tried reinstalling dnf using yum-deprecated. Nothing, yet, solved it.

msmafra gravatar imagemsmafra ( 2017-10-06 08:37:11 -0500 )edit

Question Tools

1 follower


Asked: 2017-09-29 09:45:49 -0500

Seen: 1,380 times

Last updated: Nov 13 '17