ModuleNotFoundError: 运行 yum 或 dnf 时没有名为“dnf"的模块 [英] ModuleNotFoundError: No module named 'dnf' when running yum or dnf
问题描述
几天前我想运行 dnf 但我收到以下错误
A few days ago I wanted to run dnf but I received the following error
Traceback (most recent call last):
File "/usr/bin/dnf", line 57, in <module>
from dnf.cli import main
ModuleNotFoundError: No module named 'dnf'
因此我尝试运行 yum 并收到类似的结果:
Thus I tried to run yum and I received something similar:
Traceback (most recent call last):
File "/usr/bin/yum", line 57, in <module>
from dnf.cli import main
ModuleNotFoundError: No module named 'dnf'
我不知道发生了什么,希望有人能帮我找到问题并解决它.我唯一知道的是,这可能与几天前我使用 conda 在 python 中安装 tensorflow 的事实有关.虽然现在似乎 conda 不起作用,因为我明白了:
I do not know what happened and I hope someone can help me find the problem and solve it. The only thing I know is that it might be related to the fact that a few days before I installed tensorflow in python using conda. Although it seems conda does not work now because I get this:
Traceback (most recent call last):
File "/usr/bin/conda", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3126, in <module>
@_call_aside
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3110, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3139, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 581, in _build_master
ws.require(__requires__)
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 898, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 784, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'conda==4.5.11' distribution was not found and is required by the application
我使用的是 Fedora 29谢谢!
I am using fedora 29 Thanks!
推荐答案
我遇到了同样的问题,但经过反复试验,唯一真正有效的是:
I had the same problem, but after all trial and error the only thing actually worked was:
rpm -qa python3
这将宣布您的 python3 rpm 包.
This will announce your python3 rpm package.
我已经从网上搜索并下载了它
I've searched and downloaded it from web
转到下载的目录,如:
sudo rpm -e --nodeps python3-3.7.2-4.fc29.x86_64(my python3 rpm package)
sudo rpm -i python3-3.7.2-4.fc29.x86_64.rpm
我尝试了许多其他方法,因此这不是解决该问题的唯一因素.
I tried many other methods so this'll not be a only factor that resolve that problem.
这篇关于ModuleNotFoundError: 运行 yum 或 dnf 时没有名为“dnf"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!