centos 7 使用dnf报错

[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、再安装以下软件:

bash 复制代码
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

相关推荐
吾日三省吾码4 小时前
JVM 性能调优
java
y先森5 小时前
CSS3中的伸缩盒模型(弹性盒子、弹性布局)之伸缩容器、伸缩项目、主轴方向、主轴换行方式、复合属性flex-flow
前端·css·css3
前端Hardy5 小时前
纯HTML&CSS实现3D旋转地球
前端·javascript·css·3d·html
susu10830189115 小时前
vue3中父div设置display flex,2个子div重叠
前端·javascript·vue.js
弗拉唐5 小时前
springBoot,mp,ssm整合案例
java·spring boot·mybatis
sun0077005 小时前
ubuntu dpkg 删除安装包
运维·服务器·ubuntu
海岛日记5 小时前
centos一键卸载docker脚本
linux·docker·centos
oi776 小时前
使用itextpdf进行pdf模版填充中文文本时部分字不显示问题
java·服务器
IT女孩儿6 小时前
CSS查缺补漏(补充上一条)
前端·css