安装TensorFlow Object Detection API时因cmake缺失致pyarrow编译失败
问题:虚拟环境中安装TensorFlow Object Detection API失败
在虚拟环境(venv)中安装TensorFlow Object Detection API的最后一步,出现以下错误:
-- Running cmake for pyarrow cmake -DPYTHON_EXECUTABLE=C:\Users\lenovo\Desktop\tfod\venv\Scripts\python.exe -DPython3_EXECUTABLE=C:\Users\lenovo\Desktop\tfod\venv\Scripts\python.exe "" -G "Visual Studio 15 2017 Win64" -DPYARROW_BUILD_CUDA=off -DPYARROW_BUILD_SUBSTRAIT=off -DPYARROW_BUILD_FLIGHT=off -DPYARROW_BUILD_GANDIVA=off -DPYARROW_BUILD_DATASET=off -DPYARROW_BUILD_ORC=off -DPYARROW_BUILD_PARQUET=off -DPYARROW_BUILD_PARQUET_ENCRYPTION=off -DPYARROW_BUILD_PLASMA=off -DPYARROW_BUILD_GCS=off -DPYARROW_BUILD_S3=off -DPYARROW_BUILD_HDFS=off -DPYARROW_USE_TENSORFLOW=off -DPYARROW_BUNDLE_ARROW_CPP=off -DPYARROW_BUNDLE_BOOST=off -DPYARROW_GENERATE_COVERAGE=off -DPYARROW_BOOST_USE_SHARED=on -DPYARROW_PARQUET_USE_SHARED=on -DCMAKE_BUILD_TYPE=release C:\Users\lenovo\AppData\Local\Temp\pip-install-hrduc58f\pyarrow_684de191ee6446dfaf83be823240de0a Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "C:\Users\lenovo\Desktop\tfod\venv\Scripts\cmake.exe\__main__.py", line 4, in <module> ModuleNotFoundError: No module named 'cmake' error: command 'C:\\Users\\lenovo\\Desktop\\tfod\\venv\\Scripts\\cmake.exe' failed with exit code 1 error: subprocess-exited-with-error × Building wheel for pyarrow (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. full command: 'C:\Users\lenovo\Desktop\tfod\venv\Scripts\python.exe' 'C:\Users\lenovo\Desktop\tfod\venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py' build_wheel 'C:\Users\lenovo\AppData\Local\Temp\tmp4yy68iaa' cwd: C:\Users\lenovo\AppData\Local\Temp\pip-install-hrduc58f\pyarrow_684de191ee6446dfaf83be823240de0a Building wheel for pyarrow (pyproject.toml) ... error ERROR: Failed building wheel for pyarrow Successfully built object-detection Failed to build pyarrow ERROR: Could not build wheels for pyarrow, which is required to install pyproject.toml-based projects Exception information: Traceback (most recent call last): File "C:\Users\lenovo\Desktop\tfod\venv\Lib\site-packages\pip\_internal\cli\base_command.py", line 169, in exc_logging_wrapper status = run_func(*args) ^^^^^^^^^^^^^^^ File "C:\Users\lenovo\Desktop\tfod\venv\Lib\site-packages\pip\_internal\cli\req_command.py", line 248, in wrapper return func(self, options, args) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\lenovo\Desktop\tfod\venv\Lib\site-packages\pip\_internal\commands\install.py", line 426, in run raise InstallationError( pip._internal.exceptions.InstallationError: Could not build wheels for pyarrow, which is required to install pyproject.toml-based projects Remote version of pip: 23.1 Local version of pip: 23.1 Was pip installed by pip? True Removed build tracker: 'C:\\Users\\lenovo\\AppData\\Local\\Temp\\pip-build-tracker-t_z42dfc'
核心错误:执行cmake命令时触发ModuleNotFoundError: No module named 'cmake',导致pyarrow的wheel构建失败,最终无法完成安装。
解决步骤
- 卸载虚拟环境中错误安装的Python版cmake:
pip uninstall cmake -y - 安装系统级CMake工具:
下载与Visual Studio 2017兼容的CMake版本,安装后将CMake的bin目录添加到系统环境变量PATH中,确保终端中执行cmake --version能正常返回版本信息。 - 跳过源码构建,直接安装预编译的pyarrow包:
pip install pyarrow --only-binary :all: - 重新执行TensorFlow Object Detection API的安装命令。
内容的提问来源于stack exchange,提问作者Soham Petkar
相关产品推荐
相关产品推荐

