1

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>
    from dnf.conf.config import PRIO_DEFAULT, PRIO_MAINCONFIG, PRIO_AUTOMATICCONFIG
  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

6
  • You can start by verifying dnf: rpm -V dnf
    – HoD
    Commented Sep 29, 2017 at 13:19
  • Hi @HoD. rpm -V dnf returned nothing.
    – msmafra
    Commented Sep 29, 2017 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
    Commented Sep 29, 2017 at 17:52
  • No. Nothing happened that I know of.
    – msmafra
    Commented Oct 3, 2017 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
    Commented Oct 6, 2017 at 13:38

2 Answers 2

1

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.

8
  • rpm -V python3-six returned nothing too.
    – msmafra
    Commented Sep 29, 2017 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
    Commented Sep 29, 2017 at 20:14
  • Nothing happened, also. :(
    – msmafra
    Commented Oct 3, 2017 at 12:23
  • Okay, next thing. :) Do you have any other python installed on the system?
    – mattdm
    Commented Oct 3, 2017 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
    Commented Oct 3, 2017 at 14:07
2

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .