我的环境配置在页面的另一个文章中
我通过下面的命令查到合适的版本后进行了安装
conda search mmdet
#查询的结果
Loading channels: done
# Name Version Build Channel
mmdet 2.25.0 pyh2fbee01_0 conda-forge
mmdet 2.25.0 pyh2fbee01_0 anaconda/cloud/conda-forge
最后在测试的时候发现反复出现下面的提示报错
Traceback (most recent call last):
File "demo/top_down_img_demo_with_mmdet.py", line 138, in
main()
File "demo/top_down_img_demo_with_mmdet.py", line 65, in main
assert has_mmdet, 'Please install mmdet to run the demo.'
AssertionError: Please install mmdet to run the demo.
后来找到assert这句话,发现是
然后在命令行里输入python语句
from mmdet.apis import inference_detector, init_detector
果然出现了问题
Traceback (most recent call last):
File "__init__.pxd", line 942, in numpy.import_array
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 1, in
File "/E/zhangyuqi/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmdet/apis/__init__.py", line 2, in
from .inference import (async_inference_detector, inference_detector,
File "/E/zhangyuqi/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmdet/apis/inference.py", line 12, in
from mmdet.core import get_classes
File "/E/zhangyuqi/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmdet/core/__init__.py", line 6, in
from .hook import * # noqa: F401, F403
File "/E/zhangyuqi/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmdet/core/hook/__init__.py", line 6, in
from .sync_norm_hook import SyncNormHook
File "/E/zhangyuqi/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmdet/core/hook/sync_norm_hook.py", line 8, in
from ..utils.dist_utils import all_reduce_dict
File "/E/zhangyuqi/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmdet/core/utils/__init__.py", line 4, in
from .misc import (center_of_mass, filter_scores_and_topk, flip_tensor,
File "/E/zhangyuqi/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmdet/core/utils/misc.py", line 8, in
from ..mask.structures import BitmapMasks, PolygonMasks
File "/E/zhangyuqi/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmdet/core/mask/__init__.py", line 3, in
from .structures import BaseInstanceMasks, BitmapMasks, PolygonMasks
File "/E/zhangyuqi/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmdet/core/mask/structures.py", line 7, in
import pycocotools.mask as maskUtils
File "/E/zhangyuqi/anaconda3/envs/openmmlab/lib/python3.8/site-packages/pycocotools-2.0.5-py3.8-linux-x86_64.egg/pycocotools/mask.py", line 3, in
import pycocotools._mask as _mask
File "pycocotools/_mask.pyx", line 22, in init pycocotools._mask
File "__init__.pxd", line 944, in numpy.import_array
ImportError: numpy.core.multiarray failed to import
这个版本的mmdet不兼容我的numpy
接下来就是安装合适的版本
pip install -U numpy 这个语句是更新,但不一定是合适的版本,我用这句得到了1.22.4版本,下载完就出现了错误提示
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
scipy 1.7.3 requires numpy<1.23.0,>=1.16.5, but you have numpy 1.23.4 which is incompatible.
我接着又尝试了其他的版本,都是不同的包对numpy有不同的版本限制,最终功夫不负有心人,我找到了合适目前所有包和环境的版本1.23.0
再次输入上面的验证python命令,不报错了
再次祝大家早日配好环境