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/__init__.py", line 31, in <module>
    import dnf.base
  File "/usr/lib/python3.6/site-packages/dnf/base.py", line 37, in <module>
    import dnf.conf
  File "/usr/lib/python3.6/site-packages/dnf/conf/__init__.py", line 40, in <module>
  File "/usr/lib/python3.6/site-packages/dnf/conf/config.py", line 26, in <module>
    from iniparse.compat import ParsingError, RawConfigParser as ConfigParser
  File "/usr/lib/python3.6/site-packages/iniparse/__init__.py", line 6, in <module>
    from .ini import INIConfig, change_comment_syntax
  File "/usr/lib/python3.6/site-packages/iniparse/ini.py", line 47, in <module>
    import six
ImportError: bad magic number in 'six': b'\x03\xf3\r\n'

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

  • You can start by verifying dnf: rpm -V dnf – HoD Sep 29 '17 at 13:19
  • Hi @HoD. rpm -V dnf returned nothing. – msmafra Sep 29 '17 at 13:25
  • What happened immediately before this stopped working? Did you lose power in the middle of an upgrade, or something similar? When did it last work? – mattdm Sep 29 '17 at 17:52
  • No. Nothing happened that I know of. – msmafra Oct 3 '17 at 12:43
  • I ran yum-deprecated reinstall python3-six. Tried also reinstalling dnf abd python-dnf using yum-deprecated. Nothing, yet, solved it. – msmafra Oct 6 '17 at 13:38

It sounds like the python six library is corrupt. What do you get with rpm -V python3-six? If this gives no output, the problem is elsewhere. However, if you get something like:

S.5....T.    /usr/lib/python3.6/site-packages/__pycache__/six.cpython-36.pyc

try removing the offending pyc file and try sudo dnf list again (sudo rm /usr/lib/python3.6/site-packages/__pycache__/six.cpython-36.pyc)

Note that it's not generally safe to just remove random files, but these pyc files are pre-compiled bytecode as an optimization, and will be recreated.

Note also that after recreation, rpm -Vf will still show the file as changed, because... it has. But it will probably fix this particular "bad magic number" problem.

If that doesn't work, something worse is going on.

  • rpm -V python3-six returned nothing too. – msmafra Sep 29 '17 at 20:13
  • Well, that's odd. Can you try removing /usr/lib/python3.6/site-packages/__pycache__/six*.pyc? Let's see what happens! – mattdm Sep 29 '17 at 20:14
  • Nothing happened, also. :( – msmafra Oct 3 '17 at 12:23
  • Okay, next thing. :) Do you have any other python installed on the system? – mattdm Oct 3 '17 at 12:26
  • Hi. This: python python2.7-futurize python35 python3.5m python3.6 python3-coverage python2 python2.7-pasteurize python3.5 python3.5m-config python3.6m python3-mako-render python2.7 python3 python3.5-config python3.5m-x86_64-config python3-chardetect python3-pyinotify – msmafra Oct 3 '17 at 14:07

Try looking for any possibly conflicting files:

sudo find / -name 'six.py*'

If, for example, you have a file /usr/bin/six.pyc, python will try to use that first (due to module load order). Relocating/removing this file did the trick for me.

See also: similar question on ask.fedoraproject.org

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.