English
Ask Your Question
1

How to solve broken dnf in Fedora 26

asked 2017-09-29 14:45:49 +0000

msmafra gravatar image

updated 2017-10-09 14:44:33 +0000

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

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

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

(more)
edit retag flag offensive close merge delete

4 answers

Sort by ยป oldest newest most voted
1

answered 2017-09-29 21:02:35 +0000

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

/usr/lib/python3.6/site-packages/__pycache__/six.cpython-36.opt-1.pyc
/usr/lib/python3.6/site-packages/__pycache__/six.cpython-36.pyc

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

Comments

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

msmafra ( 2017-10-06 13:35:47 +0000 )edit
1

Run

sudo find / -name 'six.py*'

and report the result

villykruse ( 2017-10-06 15:40:08 +0000 )edit
1

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 ( 2017-10-10 03:14:42 +0000 )edit
1

answered 2017-09-29 19:58:31 +0000

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

answered 2017-10-09 14:43:47 +0000

msmafra gravatar image

It returned to many lines to post here. /usr/bin/six.pyc /usr/lib/python2.7/site-packages/pkgresources/vendor/six.py /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/six.py /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/six.py /usr/lib/python2.7/site-packages/pip/_ve

edit flag offensive delete link more
0

answered 2017-09-29 15:59:47 +0000

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

Comments

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

msmafra ( 2017-10-06 13:37:11 +0000 )edit

Your Answer

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

Add Answer

[hide preview]

Use your votes!

  • Use the 30 daily voting points that you get!
  • Up-vote well framed questions that provide enough information to enable people provide answers.
  • Thank your helpers by up-voting their comments and answers. If a question you asked has been answered, accept the best answer by clicking on the checkbox on the left side of the answer.
  • Down-voting might cost you karma, but you should consider doing so for incorrect or clearly detrimental questions and answers.

Question Tools

Follow
1 follower

Stats

Asked: 2017-09-29 14:45:49 +0000

Seen: 147 times

Last updated: Oct 09