RuntimeError: Couldn’t install torch.” message

用户在 Windows 系统上通过 webui.bat 启动 Stable Diffusion WebUI v1.10.1 时触发。启动脚本检测到当前 Python 版本为 3.14.4(预期为 3.10.6),随后尝试安装 torch 失败,抛出 RuntimeError: Couldn't in

RuntimeError: Couldn't install torch." message

RuntimeError: Couldn’t install torch.” message

快速结论:该报错通常发生在启动 Stable Diffusion WebUI 时,由于 Python 版本不兼容导致 torch 安装失败。优先排查 Python 版本是否为 3.10.x,并删除旧 venv 目录后重新安装。

问题场景

用户在 Windows 系统上通过 webui.bat 启动 Stable Diffusion WebUI v1.10.1 时触发。启动脚本检测到当前 Python 版本为 3.14.4(预期为 3.10.6),随后尝试安装 torch 失败,抛出 RuntimeError: Couldn't install torch.

报错原文

INCOMPATIBLE PYTHON VERSION

This program is tested with 3.10.6 Python, but you have 3.14.4.
If you encounter an error with "RuntimeError: Couldn't install torch." message,
or any other error regarding unsuccessful package (library) installation,
please downgrade (or upgrade) to the latest version of 3.10 Python
and delete current Python and "venv" folder in WebUI's directory.

...

Installing torch and torchvision
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu121
ERROR: Could not find a version that satisfies the requirement torch==2.1.2 (from versions: 2.9.0, 2.9.1, 2.10.0, 2.11.0)
ERROR: No matching distribution found for torch==2.1.2
Traceback (most recent call last):
  ...
RuntimeError: Couldn't install torch.
Command: ... -m pip install torch==2.1.2 torchvision==0.16.2 --extra-index-url https://download.pytorch.org/whl/cu121
Error code: 1

原因分析

根本原因是 Python 版本不兼容。Stable Diffusion WebUI 在启动时要求 Python 3.10.x,而用户系统安装了 Python 3.14.4。较新的 Python 版本在构建轮子(wheels)和包依赖方面与旧版本 PyTorch(此处为 torch 2.1.2)不兼容,导致 pip 无法找到匹配的安装包。

Issue 评论确认:“A1111 currently requires Python 3.10.x.” 开发者明确表示项目仍然活跃,当前环境不支持 Python 3.14。用户使用 Python 3.10.20 时可正常工作。

环境排查

  • 检查当前 Python 版本:python --version
  • 确认 WebUI 版本:v1.10.1(Issue 用户版本)
  • 检查是否存在旧的 venv 目录(位于 WebUI 根目录下)
  • 注意 CUDA 版本(日志中指向 cu121)和 torch 版本(2.1.2)的兼容性

解决步骤

  1. 安装 Python 3.10.6:从 Python 3.10.6 官方下载 获取安装包。安装时建议选择“Add Python to PATH”并将 Python 3.10 设为系统默认。
  2. 删除旧虚拟环境:在 WebUI 根目录中删除 venv 文件夹(确保之前的 Python 3.14 环境被清理)。
  3. 重新运行启动脚本:双击 webui.bat,脚本会自动使用新安装的 Python 3.10.6 创建虚拟环境并安装依赖。
  4. 可选:使用 --skip-python-version-check:如果必须保留 Python 3.14(不推荐),可以用此参数跳过版本检测,但 torch 安装仍可能失败——此方案仅为日志中提到的备用选项,未在 Issue 中验证通过。

验证方法

启动后观察控制台输出:正常启动时不应再出现 “INCOMPATIBLE PYTHON VERSION” 提示,且 torch==2.1.2 应成功安装。在 WebUI 界面左下角可确认运行时的 Python 版本是否为 3.10.x,例如 python: 3.10.20

参考来源

AUTOMATIC1111/stable-diffusion-webui #17380

GamsGo AI

AI 工具推荐

想把多个 AI 模型放在一个入口?

GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。

了解 GamsGo AI

推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。

celebrityanime
celebrityanime
文章: 8943

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注