python-3.x - ModuleNotFoundError:没有名为“pycocotools._mask”的模块
问题描述
我正在尝试从 cocoapi(https://github.com/cocodataset/cocoapi)训练 Mask-R CNN 模型,并且此错误代码不断出现。
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-8-83356bb9cf95> in <module>
19 sys.path.append(os.path.join(ROOT_DIR, "samples/coco/")) # To find local version
20
---> 21 from pycocotools.coco import coco
22
23 get_ipython().run_line_magic('matplotlib', 'inline ')
~/Desktop/coco/PythonAPI/pycocotools/coco.py in <module>
53 import copy
54 import itertools
---> 55 from . import mask as maskUtils
56 import os
57 from collections import defaultdict
~/Desktop/coco/PythonAPI/pycocotools/mask.py in <module>
1 __author__ = 'tsungyi'
2
----> 3 import pycocotools._mask as _mask
4
5 # Interface for manipulating masks stored in RLE format.
ModuleNotFoundError: No module named 'pycocotools._mask'
我尝试了 github 'issues' 选项卡上的所有方法,但它对我根本不起作用。有没有另一种解决方案?我正在使用 Python 3.6,Linux。
解决方案
1.是否安装了正确版本的cython。也就是说,如果你使用 python2/3,你应该为 python2/3 安装 cython
pip install cython
2.你是否从这个 github 项目下载了整个 .zip 文件。也就是说,即使你只需要 PythonAPI,你也应该在这里下载所有东西
git clone https://github.com/cocodataset/cocoapi.git
或者
解压压缩文件
3.是否打开终端并在正确的文件夹下运行“make”。正确的文件夹是“Makefile”所在的文件夹
cd path/to/coco/PythonAPI/Makefile
make
差不多,问题就可以解决了。
如果没有,4 和 5 可能会有所帮助。
4.是否已经安装了正确版本的gcc
5.是否已经安装了正确版本的python-dev。也就是说,如果你使用 python3,你应该安装 python3-dev(你可以尝试“sudo apt-get install python3-dev”)。
推荐阅读
- twilio - 如何使用 twilio python 进行 SIP 出站呼叫
- sql-server - 将 SQL 查询转换为 Sybase 查询
- sql-server - SQL Server:如何对一列中的值进行数学计算
- c# - 使用 ServiceModel 通道的 WCF 客户端响应始终为 NULL
- javascript - 使用 webkitdirectory 上传目录,是否可以在上传之前过滤掉某些子目录文件夹?
- node.js - node_modules/@types/ 错误(接口“元素”不能同时扩展类型“ReactElement”
) - sql - I want where the "ReceiptDate=? should be the current system date.... and I want to write how to get the current system date in SQL
- node.js - Can you create files on Firebase after deployment?
- javascript - 单击选项卡控制按钮时如何清除页面以前的状态离子框架
- sql - SQL 从嵌套的 FROM 中选择