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

Python 3.11环境下使用Poetry无法安装bitsandbytes 0.43.1求助

解决Poetry无法安装bitsandbytes 0.43.1的问题

问题重现

执行poetry add bitsandbytes时触发如下错误:

  • Installing bitsandbytes (0.43.1): Failed

RuntimeError

Unable to find installation candidates for bitsandbytes (0.43.1)

at ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/poetry/installation/chooser.py:74 in choose_for
70│
71│ links.append(link)
72│
73│ if not links:
→ 74│ raise RuntimeError(f"Unable to find installation candidates for {package}")
75│
76│ # Get the best link
77│ chosen = max(links, key=lambda link: self._sort_key(package, link))
78│

Cannot install bitsandbytes.

使用pip install bitsandbytes仅能安装0.42.01版本,无法获取需求的0.43.1版本。

解决方案

1. 更新Poetry到最新版本

旧版本Poetry可能无法正确识别PyPI上bitsandbytes 0.43.1的兼容轮子,先完成工具更新:

poetry self update

更新后再次尝试执行poetry add bitsandbytes==0.43.1。

2. 确认Python版本与系统架构兼容性

bitsandbytes 0.43.1对运行环境有特定要求:

  • 检查你的Python版本是否在官方支持范围内(当前0.43.1支持Python 3.8~3.11)
  • 若使用Apple Silicon(arm64)Mac,PyPI官方轮子可能不兼容,需从源码编译或使用社区适配版本

3. 从源码编译安装(针对无匹配轮子的系统)

如果没有对应预编译轮子,可强制从源码安装:

# 以Mac为例,先安装编译依赖
brew install llvm

# 设置环境变量指定编译器路径
export CC=$(which clang)
export CXX=$(which clang++)
export LDFLAGS="-L$(brew --prefix llvm)/lib"
export CPPFLAGS="-I$(brew --prefix llvm)/include"

# 用Poetry强制从源码安装目标版本
poetry add --no-binary bitsandbytes bitsandbytes==0.43.1

4. 手动指定轮子URL安装

在PyPI的bitsandbytes版本页面找到与你的Python版本、系统架构匹配的0.43.1轮子下载地址,直接通过Poetry安装:

# 示例:Python 3.11 + x86_64 Linux环境
poetry add https://files.pythonhosted.org/packages/9e/9b/31f91a023a634b4a3b014e0b4352b2f424a2a7f95f785a76a3e4e3b38c5b/bitsandbytes-0.43.1-cp311-cp311-linux_x86_64.whl

5. 手动安装后同步Poetry依赖

若上述方法无效,可先通过pip安装指定版本,再让Poetry同步依赖:

# 进入Poetry虚拟环境
poetry shell

# 安装目标版本
pip install bitsandbytes==0.43.1

# 退出虚拟环境
exit

# 更新lock文件,保留已安装的版本
poetry lock --no-update

# 重新同步依赖
poetry install

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.25 04:13:19