在window端的anaconda虚拟环境中,想要安装mmdet出现了这个问题,完整的错误如下所示:
Building wheels for collected packages: pycocotools
Building wheel for pycocotools (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for pycocotools (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-37
creating build\lib.win-amd64-cpython-37\pycocotools
copying pycocotools\coco.py -> build\lib.win-amd64-cpython-37\pycocotools
copying pycocotools\cocoeval.py -> build\lib.win-amd64-cpython-37\pycocotools
copying pycocotools\mask.py -> build\lib.win-amd64-cpython-37\pycocotools
copying pycocotools_init_.py -> build\lib.win-amd64-cpython-37\pycocotools
running build_ext
cythoning pycocotools/_mask.pyx to pycocotools_mask.c
building 'pycocotools._mask' extension
C:\Users\Acer\AppData\Local\Temp\pip-build-env-4fck_2gn\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\Acer\AppData\Local\Temp\pip-install-4hy59_ky\pycocotools_12df3f2b8c5940a39d3ddbdaa5df8c1b\pycocotools_mask.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pycocotools
Failed to build pycocotools
ERROR: Could not build wheels for pycocotools, which is required to install pyproject.toml-based projects
大概就是安装mmdet时需要安装依赖pycocotools,这个是目标检测比较常见的一个工具包,然后安装这个依赖的过程中发生了错误。
问题的可能原因是没有安转Microsoft Visual C++的编译器,定位为error: Microsoft Visual C++ 14.0 or greater is required,那么现在需要的是安装一个Visual studio,为此,我安装了Visual Studio 2019的专业版本之后,随即即可正常安装pycocotools(也可以正常安装mmdet)
如下所示:文章来源:https://www.toymoban.com/news/detail-541160.html
(openmmlab) C:\Users\Acer>mim install mmdet
D:\Anaconda3\envs\openmmlab\lib\site-packages_distutils_hack_init_.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
Looking in links: https://download.openmmlab.com/mmcv/dist/cu102/torch1.10.0/index.html
Collecting mmdet
Using cached mmdet-2.25.2-py3-none-any.whl (1.4 MB)
Collecting pycocotools
Using cached pycocotools-2.0.5.tar.gz (24 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy in d:\anaconda3\envs\openmmlab\lib\site-packages (from mmdet) (1.21.6)
Collecting terminaltables
Using cached terminaltables-3.1.10-py2.py3-none-any.whl (15 kB)
Collecting matplotlib
Using cached matplotlib-3.5.3-cp37-cp37m-win_amd64.whl (7.2 MB)
Requirement already satisfied: six in d:\anaconda3\envs\openmmlab\lib\site-packages (from mmdet) (1.16.0)
Requirement already satisfied: mmcv-full>=1.3.17 in d:\anaconda3\envs\openmmlab\lib\site-packages (from mmdet) (1.6.2)
Requirement already satisfied: pyyaml in d:\anaconda3\envs\openmmlab\lib\site-packages (from mmcv-full>=1.3.17->mmdet) (6.0)
Requirement already satisfied: addict in d:\anaconda3\envs\openmmlab\lib\site-packages (from mmcv-full>=1.3.17->mmdet) (2.4.0)
Requirement already satisfied: regex in d:\anaconda3\envs\openmmlab\lib\site-packages (from mmcv-full>=1.3.17->mmdet) (2022.9.13)
Requirement already satisfied: Pillow in d:\anaconda3\envs\openmmlab\lib\site-packages (from mmcv-full>=1.3.17->mmdet) (9.2.0)
Requirement already satisfied: yapf in d:\anaconda3\envs\openmmlab\lib\site-packages (from mmcv-full>=1.3.17->mmdet) (0.32.0)
Requirement already satisfied: packaging in d:\anaconda3\envs\openmmlab\lib\site-packages (from mmcv-full>=1.3.17->mmdet) (21.3)
Collecting fonttools>=4.22.0
Using cached fonttools-4.37.4-py3-none-any.whl (960 kB)
Requirement already satisfied: python-dateutil>=2.7 in d:\anaconda3\envs\openmmlab\lib\site-packages (from matplotlib->mmdet) (2.8.2)
Requirement already satisfied: pyparsing>=2.2.1 in d:\anaconda3\envs\openmmlab\lib\site-packages (from matplotlib->mmdet) (3.0.9)
Collecting cycler>=0.10
Using cached cycler-0.11.0-py3-none-any.whl (6.4 kB)
Collecting kiwisolver>=1.0.1
Using cached kiwisolver-1.4.4-cp37-cp37m-win_amd64.whl (54 kB)
Requirement already satisfied: typing-extensions in d:\anaconda3\envs\openmmlab\lib\site-packages (from kiwisolver>=1.0.1->matplotlib->mmdet) (4.4.0)
Building wheels for collected packages: pycocotools
Building wheel for pycocotools (pyproject.toml) ... done
Created wheel for pycocotools: filename=pycocotools-2.0.5-cp37-cp37m-win_amd64.whl size=74562 sha256=cf3ea032d69b34bb03b6a7aa57dfdccefd5a4efe9b492c60c93febc553166c48
Stored in directory: c:\users\acer\appdata\local\pip\cache\wheels\85\c4\f0\7128093a134f590e4383fd60cb484960878721d98b9a515317
Successfully built pycocotools
Installing collected packages: terminaltables, kiwisolver, fonttools, cycler, matplotlib, pycocotools, mmdet
Successfully installed cycler-0.11.0 fonttools-4.37.4 kiwisolver-1.4.4 matplotlib-3.5.3 mmdet-2.25.2 pycocotools-2.0.5 terminaltables-3.1.10
Visual Studio 2019的安装,自行网上搜索即可。文章来源地址https://www.toymoban.com/news/detail-541160.html
到了这里,关于error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools“的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!