yolov5#The ‘pycocotools>=2.0‘ distribution was not found#ERROR: Failed building wheel forpycocotool

1)在pip install Pycocotools时遇到错误:ERROR: Failed building wheel for pycocotools
2)在运行yolov5中的detect.py时遇到的错误:DistributionNotFound:The ‘pycocotools>=2.0‘ distribution was not found
关于以上两个报错的解决方案为方案二!成功解决!

一从github下载yolov5的代码

https://github.com/ultralytics/YOLOv5

二根据requirement.txt安装各种包

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple

在这里插入图片描述

觉得安装地差不多了然后运行了一下detect.py,开始报错,如下图所示:pkg_resources.DistributionNotFound: The ‘pycocotools>=2.0’ distribution was not found and is required by the application 好烦恼

在这里插入图片描述

三继续下载pycocotools的包但是报错


(venv) D:\yolov5-master>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pycocotools
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pycocotools
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/de/df/056875d697c45182ed6d2ae21f62015896fdb841906fe48e7268e791c467/pycocotools-2.0.2.tar.gz (23 kB)
Requirement already satisfied: setuptools>=18.0 in d:\yolov5-master\venv\lib\site-packages (from pycocotools) (49.2.1)
Requirement already satisfied: cython>=0.27.3 in d:\yolov5-master\venv\lib\site-packages (from pycocotools) (0.29.22)
Requirement already satisfied: matplotlib>=2.1.0 in d:\yolov5-master\venv\lib\site-packages (from pycocotools) (3.3.4)
Requirement already satisfied: numpy>=1.15 in d:\yolov5-master\venv\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (1.20.1)
Requirement already satisfied: cycler>=0.10 in d:\yolov5-master\venv\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (0.10.0)
Requirement already satisfied: pillow>=6.2.0 in d:\yolov5-master\venv\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (8.1.0)
Requirement already satisfied: python-dateutil>=2.1 in d:\yolov5-master\venv\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (2.8.1)
Requirement already satisfied: kiwisolver>=1.0.1 in d:\yolov5-master\venv\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (1.3.1)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in d:\yolov5-master\venv\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (2.4.7)
Requirement already satisfied: six in d:\yolov5-master\venv\lib\site-packages (from cycler>=0.10->matplotlib>=2.1.0->pycocotools) (1.15.0)
Building wheels for collected packages: pycocotools
  Building wheel for pycocotools (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'd:\yolov5-master\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-instal
l-05jzjsot\\pycocotools\\setup.py'"'"'; __file__='"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-install-05jzjsot\\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\a
dmin\AppData\Local\Temp\pip-wheel-1g8ue7mu'
       cwd: C:\Users\admin\AppData\Local\Temp\pip-install-05jzjsot\pycocotools\
  Complete output (16 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.9
  creating build\lib.win-amd64-3.9\pycocotools
  copying pycocotools\coco.py -> build\lib.win-amd64-3.9\pycocotools
  copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.9\pycocotools
  copying pycocotools\mask.py -> build\lib.win-amd64-3.9\pycocotools
  copying pycocotools\__init__.py -> build\lib.win-amd64-3.9\pycocotools
  running build_ext
  cythoning pycocotools/_mask.pyx to pycocotools\_mask.c
  d:\yolov5-master\venv\lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will cha
nge in a later release! File: C:\Users\admin\AppData\Local\Temp\pip-install-05jzjsot\pycocotools\pycocotools\_mask.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  building 'pycocotools._mask' extension
  error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
  ----------------------------------------
  ERROR: Failed building wheel for pycocotools
  Running setup.py clean for pycocotools
Failed to build pycocotools
Installing collected packages: pycocotools
    Running setup.py install for pycocotools ... error
    ERROR: Command errored out with exit status 1:
     command: 'd:\yolov5-master\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-inst
all-05jzjsot\\pycocotools\\setup.py'"'"'; __file__='"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-install-05jzjsot\\pycocotools\\setup.py'"'"';f=getattr(tokenize,
'"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Use
rs\admin\AppData\Local\Temp\pip-record-a2naj6wr\install-record.txt' --single-version-externally-managed --compile --install-headers 'd:\yolov5-master\venv\include\si
te\python3.9\pycocotools'
         cwd: C:\Users\admin\AppData\Local\Temp\pip-install-05jzjsot\pycocotools\
    Complete output (14 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.9
    creating build\lib.win-amd64-3.9\pycocotools
    copying pycocotools\coco.py -> build\lib.win-amd64-3.9\pycocotools
    copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.9\pycocotools
    copying pycocotools\mask.py -> build\lib.win-amd64-3.9\pycocotools
    copying pycocotools\__init__.py -> build\lib.win-amd64-3.9\pycocotools
    running build_ext
    skipping 'pycocotools\_mask.c' Cython extension (up-to-date)
    building 'pycocotools._mask' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'd:\yolov5-master\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\admi
n\\AppData\\Local\\Temp\\pip-install-05jzjsot\\pycocotools\\setup.py'"'"'; __file__='"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-install-05jzjsot\\pycocotools\\s
etup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec
'"'"'))' install --record 'C:\Users\admin\AppData\Local\Temp\pip-record-a2naj6wr\install-record.txt' --single-version-externally-managed --compile --install-headers
'd:\yolov5-master\venv\include\site\python3.9\pycocotools' Check the logs for full command output.
WARNING: You are using pip version 20.2.3; however, version 21.0.1 is available.
You should consider upgrading via the 'd:\yolov5-master\venv\scripts\python.exe -m pip install --upgrade pip' command.

四然后网上找解决方案

1.1方案一

直接
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAP
在这里插入图片描述

git 不太了解,然后没有设置没用

1.2方案二

(1) **在此下载cocoapi,PythonAPI,地址:**https://github.com/philferriere/cocoapi
下载下来是cocoapi-master的压缩包,然后将压缩包解压,我放在D盘的

(2)用管理员身份打开命令行(cmd)
a)切换到D盘
b)到达cocoapi-master/PythonAPI
c)运行命令 python setup.py build_ext install
d)看提示需要Cython包,下载包pip install -i https://pypi.tuna.tsinghua.edu.cn/simple Cython
在这里插入图片描述
e)继续运行命令python setup.py build_ext install
然后出现了error:unbale to find vcvarsall.bat,所以需要安装visual studio,下载地址在这https://go.microsoft.com/fwlink/?LinkId=691126
在这里插入图片描述
下载中……
在这里插入图片描述
然后又仔细看了一眼之前安装pycocotools时候的报错
其实有两个错误,其中有一个就提示了
在这里插入图片描述
所以试一试,下载好之后怎么样(真的超级慢的
在这里插入图片描述
终于安装完成
在这里插入图片描述
f)在管理员身份打开的cmd中继续运行命令python setup.py build_ext install 这次没有报错(如下图)

在这里插入图片描述
g)然后回到pycharm的Terminal继续pip intall pycocotools包,没有报错,安装成功!
在这里插入图片描述
h)运行detect.py,Ok没有报关于pycocotools的错误啦,(虽然有新的错误哈哈哈哈哈哈,但是pycocotools这个报错完美解决,撒花!!!!!!

参考链接
1)https://github.com/philferriere/cocoapi
2)https://blog.csdn.net/gothic_1109/article/details/106019965
3)https://blog.csdn.net/benzhujie1245com/article/details/82686973?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.baidujs&dist_request_id=7a0051e9-a6cb-4a33-9e73-e50e63709197&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.baidujs

评论 19
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值