解决 `pip install open-webui` 时的编译错误:Microsoft Visual C++ 14.0 或更高版本缺失

在尝试安装 Python 包 open-webui 时,如果你遇到了如下错误信息:

复制代码
error: subprocess-exited-with-error

× Building wheel for chroma-hnswlib (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [5 lines of output]
    running bdist_wheel
    running build
    running build_ext
    building 'hnswlib' extension
    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 chroma-hnswlib
Failed to build chroma-hnswlib
ERROR: Failed to build installable wheels for some pyproject.toml based projects (chroma-hnswlib)

这通常意味着你的系统缺少必要的构建工具,特别是 Microsoft Visual C++ 14.0 或更高版本。下面将详细介绍如何解决这个问题。


解决方案

步骤一:安装 Microsoft Visual C++ 生成工具

  1. 访问 Microsoft C++ Build Tools 官网。
  2. 下载并运行安装程序。
  3. 在安装过程中,请确保勾选"C++ 生成工具"以及适用于你系统的 Windows SDK 版本(例如 Windows 10 SDK)。
  4. 完成安装后,重启计算机以确保所有更改生效。

步骤二:更新 pip 和 setuptools

确保你的 pip 和 setuptools 是最新版本,可以通过以下命令来升级它们:

bash 复制代码
python -m pip install --upgrade pip setuptools

步骤三:重新尝试安装 Open WebUI

现在,再次尝试通过 pip 安装 open-webui:

bash 复制代码
pip install open-webui

替代方案(如果问题依旧存在)

使用预编译的包

有时候,直接从源码编译可能会遇到问题,这时可以尝试强制使用预编译的二进制文件(如果有的话):

bash 复制代码
pip install chroma-hnswlib --only-binary :all:

或者,如果你希望强制源码编译(请确保已正确安装了构建工具):

bash 复制代码
pip install chroma-hnswlib --no-binary :all:

使用 Conda(推荐给已经安装了 Anaconda 或 Miniconda 的用户)

如果你正在使用 Conda 环境管理器,可以通过 Conda Forge 渠道安装 hnswlib:

bash 复制代码
conda install -c conda-forge hnswlib
pip install open-webui

注意事项

  • 确认你所安装的 Visual C++ 版本与你的 Python 架构(32位或64位)相匹配。
  • 运行命令提示符或终端时,最好以管理员权限启动。
  • 如果你在公司网络下工作,并且需要穿过防火墙或代理服务器,请检查你的网络设置是否允许下载所需的资源。
相关推荐
倒头就睡的小比特4 天前
算法竞赛C++常用的STL
c++·算法
可涵不会debug4 天前
LangChain 进阶之路:LangGraph 图工作流、有状态智能体完整入门教程
microsoft
weilx12344 天前
C++笔记-文件IO-<fcntl.h>
c++
Smileyqp沛沛4 天前
前端?C++ ?较大差异基础罗列
c++·基础·前端转c++
C语言小火车4 天前
C/C++ 为什么需要编译器?
开发语言·c++
旖旎夜光4 天前
力控面试题 01.01: 判定字符是否唯一(位运算) —— 题解
c++·学习·算法·leetcode·力控
吞下星星的少年·-·4 天前
C++ 萌新语法入门篇
c++·算法比赛
霍霍的袁4 天前
【C++】map 和 set 的使用 | 从用法到底层
开发语言·c++·学习·visual studio
another heaven4 天前
【算法/C++ MD5算法能否逆解码?原理、C++实现与同类哈希算法对比】
c++·算法·哈希算法
程序猿编码4 天前
告别改源码适配模型:纯 C++ 可配置 LLM 推理引擎,全格式全结构兼容
c++·大模型·llm·推理引擎