1)在pip install Pycocotools时遇到错误:ERROR: Failed building wheel for pycocotools
2)在运行yolov5中的detect.py时遇到的错误:DistributionNotFound:The ‘pycocotools>=2.0‘ distribution was not found
关于以上两个报错的解决方案为方案二!成功解决!
https://github.com/ultralytics/YOLOv5
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 好烦恼
(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.
直接
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAP
git 不太了解,然后没有设置没用
(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