安装Streamlit时pyarrow编译失败(CMake错误)求助
解决Streamlit安装时Failed building wheel for pyarrow的问题
问题场景
安装Streamlit时触发Failed building wheel for pyarrow错误,降级Python到3.6后问题依然存在。错误核心是执行cmake命令时出现ModuleNotFoundError: No module named 'cmake',导致pyarrow编译失败,无法完成Streamlit安装。
错误日志详情:
PS D:\Emo> pip install streamlit Collecting streamlit Using cached streamlit-1.14.1-py2.py3-none-any.whl (9.2 MB) Collecting pydeck>=0.1.dev5 Using cached pydeck-0.8.0-py2.py3-none-any.whl (4.7 MB) Requirement already satisfied: packaging>=14.1 in d:\codrs\python 3.7\lib\site-packages (from streamlit) (21.3) . . . -- Running CMake for PyArrow C++ cmake -DARROW_BUILD_DIR=build -DCMAKE_BUILD_TYPE=release -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_PREFIX=C:\Users\GAURIP~1\AppData\Local\Temp\pip-install-1g509rj0\pyarrow_a9950c5da511498d9e85239311ed4fd7\build\dist "-DPYTHON_EXECUTABLE=d:\codrs\python 3.7\python.exe" "-DPython3_EXECUTABLE=d:\codrs\python 3.7\python.exe" -DPYARROW_CXXFLAGS= -DPYARROW_WITH_DATASET=off -DPYARROW_WITH_PARQUET_ENCRYPTION=off -DPYARROW_WITH_HDFS=off -G "Visual Studio 15 2017 Win64" C:\Users\GAURIP~1\AppData\Local\Temp\pip-install-1g509rj0\pyarrow_a9950c5da511498d9e85239311ed4fd7\pyarrow/src Traceback (most recent call last): File "d:\codrs\python 3.7\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "d:\codrs\python 3.7\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "D:\Codrs\python 3.7\Scripts\cmake.exe\__main__.py", line 4, in <module> ModuleNotFoundError: No module named 'cmake' error: command 'D:\\Codrs\\python 3.7\\Scripts\\cmake.exe' failed with exit code 1 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pyarrow Failed to build pyarrow ERROR: Could not build wheels for pyarrow, which is required to install pyproject.toml-based projects
问题原因
日志显示系统调用的是Python环境Scripts目录下的cmake.exe,但该执行文件依赖的Python模块缺失,说明Python的cmake包损坏或未正确安装;另外,若系统未安装原生CMake工具,pip会尝试通过Python包编译pyarrow,进而触发该错误。
解决方案
方案1:修复Python的cmake包
- 卸载现有损坏的cmake包:
pip uninstall -y cmake
- 重新安装最新版cmake包:
pip install --upgrade cmake
- 重新执行Streamlit安装命令:
pip install streamlit
方案2:安装原生CMake工具(推荐)
若Python包方式仍失败,直接安装系统级CMake工具:
- 下载对应Windows版本的CMake安装包(建议3.20+,匹配日志中的Visual Studio 2017),安装时勾选Add CMake to system PATH选项。
- 打开新的命令提示符,验证安装:
cmake --version
- 安装预编译的pyarrow轮子(避免本地编译),再安装Streamlit:
pip install pyarrow --only-binary :all: pip install streamlit
内容的提问来源于stack exchange,提问作者Sarvesh Shinde
相关产品推荐
相关产品推荐

