You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行pip install langchain openai失败:multidict编译报错,已装C++工具仍未解决

解决Windows下Python 3.12安装langchain/openai时multidict编译失败的问题

你遇到的问题是multidict在Python 3.12环境下编译需要完整的C++构建工具链,即便安装了Build Tools也可能因组件不全导致失败。以下是几种可行的解决方法:

方法1:补全C++ Build Tools的必要组件

  • 打开已安装的Microsoft C++ Build Tools,点击"修改"按钮
  • 在工作负载列表中勾选桌面开发使用C++,确保以下核心组件被选中:
    • MSVC v143 - VS 2022 C++ x64/x86生成工具
    • 对应你Windows版本的SDK(如Windows 11 SDK)
    • C++ CMake工具 for Windows
  • 点击"修改"完成安装,重启电脑后重新执行pip install langchain openai

方法2:手动安装预编译的multidict wheel包

  • 下载适配Python 3.12和Windows架构(x64/x86)的multidict预编译.whl文件
  • 使用pip安装本地wheel文件:
    pip install "multidict-x.x.x-cp312-cp312-win_amd64.whl"
    
  • 安装完成后再执行原安装命令:pip install langchain openai

方法3:强制使用预编译包安装

  • 先升级pip到最新版本:
    python -m pip install --upgrade pip
    
  • 执行安装命令时强制使用预编译二进制包,跳过本地编译:
    pip install langchain openai --only-binary :all:
    

方法4:临时降级Python版本

如果以上方案都无效,可以暂时降级到Python 3.11版本,该版本对multidict的编译兼容性更成熟,卸载Python 3.12后安装Python 3.11,再重新执行安装命令即可。

附错误详情

Building wheels for collected packages: multidict
Building wheel for multidict (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for multidict (pyproject.toml) did not run successfully.
│ exit code: 1
...
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for multidict
Failed to build multidict
ERROR: Could not build wheels for multidict, which is required to install pyproject.toml-based projects

内容的提问来源于stack exchange,提问作者Rokibul Hasan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 10:13:24