安装CrewAI失败:VSwhere解析错误导致numpy编译受阻
问题:Windows11安装CrewAI时numpy编译失败
在Windows11笔记本执行pip install CrewAI安装CrewAI时,系统要求安装vswhere.exe,已通过安装带C++组件的MSBuild Tools完成该操作,但安装依赖的numpy(版本1.26.4)时仍报错,错误信息如下:
Collecting numpy<2,>=1 (from langchain<0.2.0,>=0.1.0->crewAI) Using cached numpy-1.26.4.tar.gz (15.8 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [21 lines of output] + D:\Program Files\python\llama3_env\Scripts\python.exe C:\Users\srira\AppData\Local\Temp\pip-install-nrzte6on\numpy_ccee6a9a4d144d588d06a6d02f9bf07e\vendored-meson\meson\meson.py setup C:\Users\srira\AppData\Local\Temp\pip-install-nrzte6on\numpy_ccee6a9a4d144d588d06a6d02f9bf07e C:\Users\srira\AppData\Local\Temp\pip-install-nrzte6on\numpy_ccee6a9a4d144d588d06a6d02f9bf07e.mesonpy-eygusz5h -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=C:\Users\srira\AppData\Local\Temp\pip-install-nrzte6on\numpy_ccee6a9a4d144d588d06a6d02f9bf07e.mesonpy-eygusz5h\meson-python-native-file.ini The Meson build system Version: 1.2.99 Source dir: C:\Users\srira\AppData\Local\Temp\pip-install-nrzte6on\numpy_ccee6a9a4d144d588d06a6d02f9bf07e Build dir: C:\Users\srira\AppData\Local\Temp\pip-install-nrzte6on\numpy_ccee6a9a4d144d588d06a6d02f9bf07e.mesonpy-eygusz5h Build type: native build Project name: NumPy Project version: 1.26.4 WARNING: Failed to activate VS environment: Could not parse vswhere.exe output ..\meson.build:1:0: ERROR: Unknown compiler(s): [['icl'], ['cl'], ['cc'], ['gcc'], ['clang'], ['clang-cl'], ['pgcc']] The following exception(s) were encountered: Running `icl ""` gave "[WinError 2] The system cannot find the file specified" Running `cl /?` gave "[WinError 2] The system cannot find the file specified" Running `cc --version` gave "[WinError 2] The system cannot find the file specified" Running `gcc --version` gave "[WinError 2] The system cannot find the file specified" Running `clang --version` gave "[WinError 2] The system cannot find the file specified" Running `clang-cl /?` gave "[WinError 2] The system cannot find the file specified" Running `pgcc --version` gave "[WinError 2] The system cannot find the file specified" A full log can be found at C:\Users\srira\AppData\Local\Temp\pip-install-nrzte6on\numpy_ccee6a9a4d144d588d06a6d02f9bf07e\.mesonpy-eygusz5h\meson-logs\meson-log.txt [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details.
解决步骤
强制使用预编译二进制包:跳过源码编译,直接安装numpy的预编译wheel包,执行命令:
pip install numpy==1.26.4 --only-binary :all:安装完成后再重新执行
pip install CrewAI。验证MSBuild Tools组件:确认安装的MSBuild Tools包含以下核心组件:
- MSVC v143 生成工具(或对应版本的编译器)
- Windows SDK(匹配系统版本)
- C++ CMake 工具
若组件不全,打开Visual Studio Installer补充安装,完成后重启终端。
使用VS命令行环境执行安装:找到系统中安装的
x64 Native Tools Command Prompt for VS 2022(版本对应你的MSBuild Tools),打开该命令提示符后,激活Python虚拟环境,再执行pip install CrewAI,确保编译环境变量被正确加载。更新pip及相关工具:先升级pip、setuptools和wheel,避免工具版本过低导致的兼容性问题:
pip install --upgrade pip setuptools wheel
内容的提问来源于stack exchange,提问作者Sri
相关产品推荐
相关产品推荐

