CentOS7安装dnf后无法运行并报错:ImportError: No module named _conf

CentOS7通过epel的yum安装dnf后,运行dnf会报以下错误:

Traceback (most recent call last):

  File "/usr/bin/dnf", line 57, in

    from dnf.cli import main

  File "/usr/lib/python2.7/site-packages/dnf/__init__.py", line 30, in

    import dnf.base

  File "/usr/lib/python2.7/site-packages/dnf/base.py", line 29, in

    import libdnf.transaction

  File "/usr/lib64/python2.7/site-packages/libdnf/__init__.py", line 3, in

    from . import conf

  File "/usr/lib64/python2.7/site-packages/libdnf/conf.py", line 17, in

    _conf = swig_import_helper()

  File "/usr/lib64/python2.7/site-packages/libdnf/conf.py", line 16, in swig_import_helper

    return importlib.import_module('_conf')

  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module

    __import__(name)

ImportError: No module named _conf

 

其实最主要的错误就是最后一条:ImportError: No module named _conf

 

github上找到解决办法:

先升级python:

yum update python*

 

再安装以下软件:

yum install dnf-data dnf-plugins-core libdnf-devel libdnf python2-dnf-plugin-migrate dnf-automatic

 

 

再次运行dnf,就正常了。

你可能感兴趣的:(Linux,centos,dnf,No,module,named,_conf)