pip 安装 老版本 pytorch 的一个容易迷惑的错误
当用 pip 安装老版本 pytorch 时,遇到如下错误提示
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu118
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://download.pytorch.org/whl/cu118
ERROR: Could not find a version that satisfies the requirement torch==2.5.1 (from versions: none)
ERROR: No matching distribution found for torch==2.5.1
这是 pip 一个比较容易误导人的地方:它不会直接告诉你“Python 版本不匹配”,而是把“不满足当前环境条件的包版本”过滤掉,最后显示“找不到版本”。
错误:
ERROR: Could not find a version that satisfies the requirement torch==2.5.1
(from versions: none)
ERROR: No matching distribution found for torch==2.5.1
实际含义不是:
PyPI 上没有 torch 2.5.1
而是:
我在当前 Python + 系统 + 架构条件下,没有找到可安装的 torch 2.5.1 wheel。
pip 查找过程
假设你当前:
Python 3.13
Windows 10
x64
执行:
pip install torch==2.5.1 --index-url https://download.pytorch.org/whl/cu118
pip 去索引查找:
torch 2.5.1
服务器实际上有:
torch-2.5.1+cu118-cp39-win_amd64.whl
torch-2.5.1+cu118-cp310-win_amd64.whl
torch-2.5.1+cu118-cp311-win_amd64.whl
torch-2.5.1+cu118-cp312-win_amd64.whl
其中:
cp39 = Python 3.9
cp310 = Python 3.10
cp311 = Python 3.11
cp312 = Python 3.12
但是没有:
cp313
于是 pip 过滤:
torch 2.5.1
├── cp39 ❌ 当前不是 Python 3.9
├── cp310 ❌
├── cp311 ❌
├── cp312 ❌
└── cp313 不存在
最后:
from versions: none
为什么 pip 不显示原因?
因为 pip 的设计目标是通用包管理器,它面对的不只是 Python 版本,还要考虑:
- Python ABI
- 操作系统
- CPU 架构
- CUDA wheel
- manylinux 标签
- 编译平台
例如:
一个包可能有:
numpy
├── cp311-win_amd64
├── cp312-win_amd64
├── cp313-win_amd64
torch
├── cp39-cu118
├── cp310-cu118
├── cp311-cu118
├── cp312-cu118
pip 只告诉:
没有符合条件的发行包
而不会展开解释:
因为 Python 是 cp313。
如何自己确认原因?
使用:
python --version
例如:
Python 3.13.5
再看:
python -c "import sys;print(sys.version)"
更详细查看 pip 判断过程
增加日志:
pip install torch==2.5.1 -v
或者:
pip install torch==2.5.1 -vv
你会看到类似:
Skipping link:
requires-python ...
或者:
none of the wheel's tags match
uv 为什么更容易避免这个问题?
uv 在创建环境时:
uv venv --python 3.11
已经固定:
CPython 3.11
然后:
uv pip install torch==2.5.1
它会明确知道:
cp311-win_amd64
所以匹配成功。
情况总结
我之前:
nvidia-smi:
CUDA 13.0
不是问题。
CUDA 也不是问题。
真正原因:
Python版本
↓
没有对应 torch wheel
↓
pip过滤全部版本
↓
显示 from versions:none
对于我的 GTX 1080 Ti:
推荐固定:
Python 3.11.x
PyTorch 2.5.1+cu118
torchvision 0.20.1
torchaudio 2.5.1
这样可以避免 PyTorch、Transformers、Qwen3-Embedding 后续兼容问题。

浙公网安备 33010602011771号