【问题标题】:ModuleNotFoundError: No module named 'utils'ModuleNotFoundError:没有名为“utils”的模块
【发布时间】:2018-09-07 18:23:52
【问题描述】:
我正在尝试使用我的网络摄像头作为输入在 Tensorflow 中运行 object_detection API。
错误提示:“from utils import label_map_util ModuleNotFoundError: No module named 'utils'”
这与线条有关:
from utils import label_map_util
from utils import visualization_utils as vis_util
我试过“pip install util”似乎可以工作,但不能解决问题。我还重新安装了多个版本的 protobuf,因为网上的其他问题似乎有这个作为解决方案。安装 protoc 时我没有收到任何错误,所以我认为这不是问题。
我在带有 tensorflow-gpu 的 windows 10 上使用 python 3.6。
【问题讨论】:
标签:
python
opencv
tensorflow
【解决方案1】:
你从哪个文件夹运行你的 python 脚本?
为了能够直接访问“utils”模块,您需要在<models-master>\research\object_detection 文件夹中运行脚本。
【解决方案2】:
-
不是在对象检测文件夹中运行脚本,而是附加
通过编写脚本中的 tensorflow 对象检测路径
import sys
sys.path.append('PATH_TO_TENSORFLOW_OBJECT_DETECTION_FOLDER')
-
例如,我的 ubuntu 系统中的“PATH_TO_TENSORFLOW_OBJECT_DETECTION_FOLDER”是
/home/dc-335/Documents/Softwares/tensorflow/models/research/object_detection
干杯,你做到了!!
【解决方案3】:
在utils前面添加object_detection:
# from utils import label_map_util
# from utils import visualization_utils as vis_util
from object_detection.utils import label_map_util
from object_detection.utils import visualization_utils as vis_util
【解决方案4】:
我使用了一种更快的方法来修复它。
我从 models\research\object_detection 复制了 utils 文件夹,并将其粘贴到与需要 utils 的 python 文件相同的目录中
【解决方案5】:
安装没有通过,您会注意到项目文件夹中没有名为 model_utils 的模块。
卸载它pip uninstall django-model-utils 然后再次安装它pip install django-model-utils 在您的项目文件夹中一个名为 model_utils 的新应用程序。