解决 `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

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

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位)相匹配。
  • 运行命令提示符或终端时,最好以管理员权限启动。
  • 如果你在公司网络下工作,并且需要穿过防火墙或代理服务器,请检查你的网络设置是否允许下载所需的资源。
相关推荐
2401_841495647 小时前
【操作系统】进程同步与互斥实验报告
c++·算法·操作系统·进程·并发·同步·互斥
fqbqrr8 小时前
2607C++,soui与安卓
c++·soui
大郭鹏宇9 小时前
基于 LangGraph 构建智能分诊系统(一):项目概述与环境搭建
大数据·人工智能·microsoft·langchain
fqbqrr11 小时前
2607C++,使用微软detours勾挂工具
c++
DisonTangor14 小时前
【微软开源】Mage-Flow 深度解读:微软4B参数图像生成与编辑模型,单卡A100仅需0.59秒
人工智能·microsoft·ai作画·开源·aigc
蓝悦无人机14 小时前
C++基础 — 函数总结
开发语言·c++
我不是懒洋洋15 小时前
从零实现一个分布式监控:Prometheus的核心设计
c++
An_s16 小时前
c++对接pdfium(一)win系统篇
开发语言·c++
众少成多积小致巨16 小时前
C++ 规范参考(上)
c++
一拳一个呆瓜19 小时前
【STL】iostream 编程:使用提取运算符
c++·stl