[root@localhost ~]# dnf --version
Traceback (most recent call last):
File "/usr/bin/dnf", line 57, in <module>
from dnf.cli import main
File "/usr/lib/python2.7/site-packages/dnf/__init__.py", line 30, in <module>
import dnf.base
File "/usr/lib/python2.7/site-packages/dnf/base.py", line 29, in <module>
import libdnf.transaction
File "/usr/lib64/python2.7/site-packages/libdnf/__init__.py", line 3, in <module>
from . import conf
File "/usr/lib64/python2.7/site-packages/libdnf/conf.py", line 17, in <module>
_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
解决方法:
因为服务器环境为CentOS 7,没有完全预装在 CentOS 7 中,所以需要先全安装DNF。
# yum install epel-release
# yum install dnf
# dnf --version
二、解决办法
1、先升级python:
#yum update python*
2、再安装以下软件:
yum -y install dnf-data dnf-plugins-core libdnf-devel libdnf python2-dnf-plugin-migrate dnf-automatic
3、测试
[root@localhost ~]# dnf --version
4.0.9
Installed: dnf-0:4.0.9.2-2.el7_9.noarch at Tue 09 Apr 2024 06:06:01 PM CST
Built : CentOS BuildSystem <http://bugs.centos.org> at Wed 07 Apr 2021 03:52:38 PM CST
Installed: rpm-0:4.11.3-48.el7_9.x86_64 at Tue 09 Apr 2024 06:13:58 PM CST
Built : CentOS BuildSystem <http://bugs.centos.org> at Wed 24 Nov 2021 04:33:39 PM CST
文章来源:https://www.toymoban.com/news/detail-853826.html
文章来源地址https://www.toymoban.com/news/detail-853826.html
到了这里,关于centos 7 使用dnf报错的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!