pycocotools安装故障排除

2024-09-30 22:15:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用Tensorflow的对象检测模型,需要安装Pycools。我在Windows10机器上的python(3)虚拟环境中执行此操作。在Windows上运行这个程序似乎有一些已知的问题,我很确定我已经尝试过了

我尝试过pip安装Pycools,但出现以下错误(无法构建控制盘):

(env) PS C:\Users\la01043601\ML_CameraVision\humanDetection> pip install pycocotools
Collecting pycocotools
  Using cached pycocotools-2.0.2.tar.gz (23 kB)
Requirement already satisfied: setuptools>=18.0 in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from pycocotools) (56.0.0)
Requirement already satisfied: cython>=0.27.3 in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from pycocotools) (0.29.23)
Requirement already satisfied: matplotlib>=2.1.0 in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from pycocotools) (3.4.2)
Requirement already satisfied: pyparsing>=2.2.1 in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (2.4.7)
Requirement already satisfied: cycler>=0.10 in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (0.10.0)
Requirement already satisfied: pillow>=6.2.0 in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (8.2.0)
Requirement already satisfied: numpy>=1.16 in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (1.19.5)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (1.3.1)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (2.8.1)
Requirement already satisfied: six in c:\users\la01043601\ml_cameravision\humandetection\env\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: 'c:\users\la01043601\ml_cameravision\humandetection\env\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-install-hjka7e0k\\pycocotools_91d3c7ee2ad946f292455cc0fc685c5f\\setup.py'"'"'; __file__='"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-install-hjka7e0k\\pycocotools_91d3c7ee2ad946f292455cc0fc685c5f\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\la01043601\AppData\Local\Temp\pip-wheel-i_wesduj'
       cwd: C:\Users\la01043601\AppData\Local\Temp\pip-install-hjka7e0k\pycocotools_91d3c7ee2ad946f292455cc0fc685c5f\
  Complete output (23 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
  c:\users\la01043601\ml_cameravision\humandetection\env\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\la01043601\AppData\Local\Temp\pip-install-hjka7e0k\pycocotools_91d3c7ee2ad946f292455cc0fc685c5f\pycocotools\_mask.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  building 'pycocotools._mask' extension
  creating build\temp.win-amd64-3.9
  creating build\temp.win-amd64-3.9\Release
  creating build\temp.win-amd64-3.9\Release\common
  creating build\temp.win-amd64-3.9\Release\pycocotools
  C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\numpy\core\include -I./common -Ic:\users\la01043601\ml_cameravision\humandetection\env\include -IC:\Python39\include -IC:\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include /Tc./common/maskApi.c /Fobuild\temp.win-amd64-3.9\Release\./common/maskApi.obj
  maskApi.c
  ./common/maskApi.c(8): fatal error C1083: Cannot open include file: 'math.h': No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
  ----------------------------------------
  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: 'c:\users\la01043601\ml_cameravision\humandetection\env\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-install-hjka7e0k\\pycocotools_91d3c7ee2ad946f292455cc0fc685c5f\\setup.py'"'"'; __file__='"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-install-hjka7e0k\\pycocotools_91d3c7ee2ad946f292455cc0fc685c5f\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\la01043601\AppData\Local\Temp\pip-record-crzypf9k\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\la01043601\ml_cameravision\humandetection\env\include\site\python3.9\pycocotools'
         cwd: C:\Users\la01043601\AppData\Local\Temp\pip-install-hjka7e0k\pycocotools_91d3c7ee2ad946f292455cc0fc685c5f\
    Complete output (21 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
    creating build\temp.win-amd64-3.9
    creating build\temp.win-amd64-3.9\Release
    creating build\temp.win-amd64-3.9\Release\common
    creating build\temp.win-amd64-3.9\Release\pycocotools
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\numpy\core\include -I./common -Ic:\users\la01043601\ml_cameravision\humandetection\env\include -IC:\Python39\include -IC:\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include /Tc./common/maskApi.c /Fobuild\temp.win-amd64-3.9\Release\./common/maskApi.obj
    maskApi.c
    ./common/maskApi.c(8): fatal error C1083: Cannot open include file: 'math.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\la01043601\ml_cameravision\humandetection\env\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-install-hjka7e0k\\pycocotools_91d3c7ee2ad946f292455cc0fc685c5f\\setup.py'"'"'; __file__='"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-install-hjka7e0k\\pycocotools_91d3c7ee2ad946f292455cc0fc685c5f\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\la01043601\AppData\Local\Temp\pip-record-crzypf9k\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\la01043601\ml_cameravision\humandetection\env\include\site\python3.9\pycocotools' Check the logs for full command output.

我已经尝试了Phil Ferriere的存储库中的修复(仍然无法构建轮子,找不到math.h文件):

(env) PS C:\Users\la01043601\ML_CameraVision\humanDetection> pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
Collecting git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
  Cloning https://github.com/philferriere/cocoapi.git to c:\users\la01043601\appdata\local\temp\pip-req-build-htao1r08
  Running command git clone -q https://github.com/philferriere/cocoapi.git 'C:\Users\la01043601\AppData\Local\Temp\pip-req-build-htao1r08'
Building wheels for collected packages: pycocotools
  Building wheel for pycocotools (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\la01043601\ml_cameravision\humandetection\env\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-htao1r08\\PythonAPI\\setup.py'"'"'; __file__='"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-htao1r08\\PythonAPI\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\la01043601\AppData\Local\Temp\pip-wheel-kktx8s70'
       cwd: C:\Users\la01043601\AppData\Local\Temp\pip-req-build-htao1r08\PythonAPI
  Complete output (20 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
  building 'pycocotools._mask' extension
  creating build\temp.win-amd64-3.9
  creating build\temp.win-amd64-3.9\common
  creating build\temp.win-amd64-3.9\Release
  creating build\temp.win-amd64-3.9\Release\pycocotools
  C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\numpy\core\include -I../common -Ic:\users\la01043601\ml_cameravision\humandetection\env\include -IC:\Python39\include -IC:\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include /Tc../common/maskApi.c /Fobuild\temp.win-amd64-3.9\Release\../common/maskApi.obj
  maskApi.c
  ../common/maskApi.c(8): fatal error C1083: Cannot open include file: 'math.h': No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
  ----------------------------------------
  ERROR: Failed building wheel for pycocotools
  Running setup.py clean for pycocotools
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\la01043601\ml_cameravision\humandetection\env\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-htao1r08\\PythonAPI\\setup.py'"'"'; __file__='"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-htao1r08\\PythonAPI\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' clean --all
       cwd: C:\Users\la01043601\AppData\Local\Temp\pip-req-build-htao1r08
  Complete output (11 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\la01043601\AppData\Local\Temp\pip-req-build-htao1r08\PythonAPI\setup.py", line 25, in <module>
      cythonize(ext_modules)
    File "c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\Cython\Build\Dependencies.py", line 965, in cythonize
      module_list, module_metadata = create_extension_list(
    File "c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\Cython\Build\Dependencies.py", line 815, in create_extension_list
      for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't match any files" % filepattern):
    File "c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\Cython\Build\Dependencies.py", line 114, in nonempty
      raise ValueError(error_msg)
  ValueError: 'pycocotools/_mask.pyx' doesn't match any files
  ----------------------------------------
  ERROR: Failed cleaning build dir 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: 'c:\users\la01043601\ml_cameravision\humandetection\env\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-htao1r08\\PythonAPI\\setup.py'"'"'; __file__='"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-htao1r08\\PythonAPI\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\la01043601\AppData\Local\Temp\pip-record-ok0x1q7g\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\la01043601\ml_cameravision\humandetection\env\include\site\python3.9\pycocotools'
         cwd: C:\Users\la01043601\AppData\Local\Temp\pip-req-build-htao1r08\PythonAPI
    Complete output (9 lines):
    running install
    running build
    running build_py
    running build_ext
    building 'pycocotools._mask' extension
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\numpy\core\include -I../common -Ic:\users\la01043601\ml_cameravision\humandetection\env\include -IC:\Python39\include -IC:\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include /Tc../common/maskApi.c /Fobuild\temp.win-amd64-3.9\Release\../common/maskApi.obj
    maskApi.c
    ../common/maskApi.c(8): fatal error C1083: Cannot open include file: 'math.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\la01043601\ml_cameravision\humandetection\env\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-htao1r08\\PythonAPI\\setup.py'"'"'; __file__='"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-htao1r08\\PythonAPI\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\la01043601\AppData\Local\Temp\pip-record-ok0x1q7g\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\la01043601\ml_cameravision\humandetection\env\include\site\python3.9\pycocotools' Check the logs for full command output.

我尝试安装VisualC++构建工具(2015版本,许多其他的答案推荐),但是错误的是它无法找到/下载安装包,所以我确定我已经更新了2019个构建工具,它们被添加到我的路径中。 我得到的错误是like this one。我还关注了该解决方案底部的视频,但没有任何帮助

我尝试使用建议的Pycools windows安装(Pycools windows),这会产生以下错误:

(env) PS C:\Users\la01043601\ML_CameraVision\humanDetection> pip install cocoapi-windows
ERROR: Could not find a version that satisfies the requirement cocoapi-windows (from versions: none)
ERROR: No matching distribution found for cocoapi-windows
(env) PS C:\Users\la01043601\ML_CameraVision\humanDetection> pip install pycocotools-windows
ERROR: Could not find a version that satisfies the requirement pycocotools-windows (from versions: none)
ERROR: No matching distribution found for pycocotools-windows

Python和pip在我的Windows路径上。我束手无策。由于这个原因,我放弃了一个教程,只是为了发现下一个教程也有pycocotools依赖项

(也接受不使用Pycools的Tensorflow对象检测教程的建议!需要一个像样的教程,因为我是初学者)

编辑:现在也尝试以以下方式运行setup.py文件,仍然存在找不到math.h文件的问题

(env) PS C:\Users\la01043601\ML_CameraVision\humanDetection\sandbox\cocoapi\PythonAPI> python setup.py build_ext --inplace
Compiling pycocotools/_mask.pyx because it changed.
[1/1] Cythonizing pycocotools/_mask.pyx
C:\Users\la01043601\ML_CameraVision\humanDetection\env\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\la01043601\ML_CameraVision\humanDetection\sandbox\cocoapi\PythonAPI\pycocotools\_mask.pyx
  tree = Parsing.p_module(s, pxd, full_module_name)
running build_ext
building 'pycocotools._mask' extension
creating build
creating build\temp.win-amd64-3.9
creating build\temp.win-amd64-3.9\common
creating build\temp.win-amd64-3.9\Release
creating build\temp.win-amd64-3.9\Release\pycocotools
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\la01043601\ML_CameraVision\humanDetection\env\lib\site-packages\numpy\core\include -I../common -IC:\Users\la01043601\ML_CameraVision\humanDetection\env\include -IC:\Python39\include -IC:\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include /Tc../common/maskApi.c /Fobuild\temp.win-amd64-3.9\Release\../common/maskApi.obj
maskApi.c
../common/maskApi.c(8): fatal error C1083: Cannot open include file: 'math.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2

Edit Edit我忘了提到,在过去几天里,我还尝试对math.h error进行故障排除,这建议将include语句从“math.h”切换到“cmath”,并使用“quotes”而不是尖括号,由于这是在从下载的repo安装时发生的,我甚至将repo分叉,因此进行了更改my version从那里下载。错误如下(现在与丢失的'crtdbg.h'文件有关,我不明白构建工具中的所有东西是如何工作的):

(env) PS C:\Users\la01043601\ML_CameraVision\humanDetection> pip install git+https://github.com/Broccoli-Hunter/cocoapi.git#subdirectory=PythonAPI
Collecting git+https://github.com/Broccoli-Hunter/cocoapi.git#subdirectory=PythonAPI
  Cloning https://github.com/Broccoli-Hunter/cocoapi.git to c:\users\la01043601\appdata\local\temp\pip-req-build-atepfcnd
  Running command git clone -q https://github.com/Broccoli-Hunter/cocoapi.git 'C:\Users\la01043601\AppData\Local\Temp\pip-req-build-atepfcnd'
Building wheels for collected packages: pycocotools
  Building wheel for pycocotools (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\la01043601\ml_cameravision\humandetection\env\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-atepfcnd\\PythonAPI\\setup.py'"'"'; __file__='"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-atepfcnd\\PythonAPI\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\la01043601\AppData\Local\Temp\pip-wheel-4bje9txk'
       cwd: C:\Users\la01043601\AppData\Local\Temp\pip-req-build-atepfcnd\PythonAPI
  Complete output (20 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
  building 'pycocotools._mask' extension
  creating build\temp.win-amd64-3.9
  creating build\temp.win-amd64-3.9\common
  creating build\temp.win-amd64-3.9\Release
  creating build\temp.win-amd64-3.9\Release\pycocotools
  C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\numpy\core\include -I../common -Ic:\users\la01043601\ml_cameravision\humandetection\env\include -IC:\Python39\include -IC:\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include /Tc../common/maskApi.c /Fobuild\temp.win-amd64-3.9\Release\../common/maskApi.obj
  maskApi.c
  C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include\yvals.h(12): fatal error C1083: Cannot open include file: 'crtdbg.h': No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
  ----------------------------------------
  ERROR: Failed building wheel for pycocotools
  Running setup.py clean for pycocotools
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\la01043601\ml_cameravision\humandetection\env\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-atepfcnd\\PythonAPI\\setup.py'"'"'; __file__='"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-atepfcnd\\PythonAPI\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' clean --all
       cwd: C:\Users\la01043601\AppData\Local\Temp\pip-req-build-atepfcnd
  Complete output (11 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\la01043601\AppData\Local\Temp\pip-req-build-atepfcnd\PythonAPI\setup.py", line 25, in <module>
      cythonize(ext_modules)
    File "c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\Cython\Build\Dependencies.py", line 965, in cythonize
      module_list, module_metadata = create_extension_list(
    File "c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\Cython\Build\Dependencies.py", line 815, in create_extension_list
      for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't match any files" % filepattern):
    File "c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\Cython\Build\Dependencies.py", line 114, in nonempty
      raise ValueError(error_msg)
  ValueError: 'pycocotools/_mask.pyx' doesn't match any files
  ----------------------------------------
  ERROR: Failed cleaning build dir for pycocotools
Failed to build pycocotools

Tags: pippybuildenvincludelibsetupml