Python 导入错误:没有名为 easydict 的模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43732185/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 23:21:10  来源:igfitidea点击:

ImportError: No module named easydict

pythonimporterror

提问by Hadi GhahremanNezhad

I'm trying to run the demo of py-faster-rcnn based on this github page. I have done all the previous steps. But When I try to run the deo with python ./tools/demo.py --gpu 0 --net vgg16I get this error:

我正在尝试基于这个 github page运行 py-faster-rcnn 的演示。我已经完成了前面的所有步骤。但是当我尝试使用 deo 运行时,出现python ./tools/demo.py --gpu 0 --net vgg16此错误:

Traceback (most recent call last):
File "./tools/demo.py", line 17, in
from fast_rcnn.config import cfg
File "/home/hadi/Software/py-faster-rcnn/tools/../lib/fast_rcnn/config.py", line 23, in
from easydict import EasyDict as edict
ImportError: No module named easydict

I have installed easydict with both these commands:

我已经用这两个命令安装了easydict:

sudo pip install easydict

sudo pip install easydict

pip install easydict

pip install easydict

Is this related to python path? I have installed both python 2.7 and 3.5. Since then I get all these python related errors. For example I have installed tensorflowfor both python 2 and 3. But with python 2 it always says:

这与python路径有关吗?我已经安装了 python 2.7 和 3.5。从那时起,我得到了所有这些与 python 相关的错误。例如,我已经为 python 2 和 3安装了tensorflow。但是对于 python 2,它总是说:

No module named tensorflow

没有名为 tensorflow 的模块

How can I fix this?

我怎样才能解决这个问题?

OS: Ubuntu 16.04

操作系统:Ubuntu 16.04

采纳答案by orvi

I would suggest trying the following:

我建议尝试以下方法:

First, check if easydict is installed or not On your terminal run:

首先,检查是否安装了easydict 在你的终端上运行:

python

from easydict import EasyDict

If this doesn't give an error then you have easydict installed. I had installed easydict using Anaconda:

如果这没有给出错误,那么您已经安装了easydict。我已经使用 Anaconda 安装了 easydict:

conda install -c https://conda.binstar.org/auto easydict

Next, if this is working check if you have pip installed (It should have come installed with Anaconda):

接下来,如果这可以正常工作,请检查您是否安装了 pip(它应该与 Anaconda 一起安装):

which pip

This command should give output as /data/username/anaconda2/bin/pip

这个命令应该给出输出 /data/username/anaconda2/bin/pip

If this is the output then pip was installed with anaconda and not apt-get. In this case you should not use sudo while using pip and while running the code.

如果这是输出,则 pip 与 anaconda 一起安装,而不是 apt-get。在这种情况下,您不应在使用 pip 和运行代码时使用 sudo。

So, you should try running the code the following way:

因此,您应该尝试按以下方式运行代码:

bash build/demo.py

after that, if still the issue occurs add this following line to your demo.pyfile

之后,如果问题仍然存在,请将以下行添加到您的demo.py文件中

import sys
sys.path.append('/usr/local/lib/python2.7/dist-packages/')

回答by sasebot

Try the following command in terminal :

sudo pip2 install easydict

在终端中尝试以下命令:

sudo pip2 install easydict

This worked for me well .

这对我很有效。