在Windows10下运行YOLOv5的train.py报错:
ERROR: Command errored out with exit status 1:
command: 'D:\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\46653\\AppData\\Local\\Temp\\pip-install-j33342g5\\pycocotools\\setup.py'"'"'; __file__='"'"'C:\\Users\\46653\\AppData\\Local\\Temp\\pip-install-j33342g5\\pycocotools\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\46653\AppData\Local\Temp\pip-wheel-0xpeseyp' --python-tag cp37
cwd: C:\Users\46653\AppData\Local\Temp\pip-install-j33342g5\pycocotools\
Complete output (13 lines):
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\pycocotools
copying pycocotools\coco.py -> build\lib.win-amd64-3.7\pycocotools
copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.7\pycocotools
copying pycocotools\mask.py -> build\lib.win-amd64-3.7\pycocotools
copying pycocotools\__init__.py -> build\lib.win-amd64-3.7\pycocotools
running build_ext
building 'pycocotools._mask' extensionrequirements: pycocotools>=2.0 not found and is required by YOLOv5
大概意思是环境中缺少pycocotools,尝试过pip install pycocotools、conda install pycocotools、pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI。全部安装失败。
- 在缺少这种关键组件时我一般都会打开这种链接:https://pypi.tuna.tsinghua.edu.cn/simple/pycocotools/ (https://download.pytorch.org/whl/torch_stable.html)
地址最后/ /中间一般是需要下载的文件名称。 - 下载好文件或者whl后,将文件放到所用环境下的文件夹里面,在该文件夹下打开终端,
若是whl文件,则输入pip install +文件名.whl。
pycocotools-2.0.2压缩包解压后得到pycocotools文件夹,此文件夹移动到所用环境下,找到解释器环境里面的文件夹即可,此时打开pycocotools文件夹,右击在终端打开。
运行以下命令:
python setup.py build_ext --inplace
python setup.py build_ext install
-
在运行第一个命令时会出现 error: Microsoft Visual C++ 14.0 is required.
唯一办法是安装Visual Studio ,安装时选择使用C++桌面开发
安装步骤参考【Tools】Visual Studio 2017下载和安装_嵌入式开发工程师—欢迎大家一起交流-优快云博客https://blog.youkuaiyun.com/dengjin20104042056/article/details/82561588 -
安装之后重启,执行前面两个命令后命令端显示:Finished processing dependencies for pycocotools==2.0.2
在环境终端下输入conda list,可以看到pycocotools表示安装成功。