今天在使用 'uv pip download’时,发现报错了具体报错信息如下:
error: unrecognized subcommand 'download'
Usage: uv pip [OPTIONS] <COMMAND>
For more information, try '--help'.
这个错误表明当前使用的 uv
版本不支持 download
子命令。以下是详细解决方案:
1. 原因分析
uv
在 2025 年最新版本中已重构包管理命令体系:
pip download
功能被整合到cache
子系统- 新版本采用
uv cache fetch
作为替代方案
2. 解决方案
2.1 现代版本(>=0.2.0)推荐方式
# 下载依赖到缓存目录
uv cache fetch -r requirements.txt --target .uv-cache
# 验证缓存完整性
uv cache verify .uv-cache
2.2 兼容旧版(<0.2.0)的替代方案
# 使用原生pip下载后导入uv缓存
python -m pip download -d ./pkgs -r requirements.txt
uv cache import ./pkgs --format=wheel
3. 版本检查与升级
# 查看当前版本
uv --version
# 升级到最新版(需网络)
curl -sSL https://install.uv.python.rs | sh
4. 典型工作流示例
# 完整离线部署流程
uv pip compile requirements.in -o uv.lock
uv cache fetch -r uv.lock --platform manylinux2024_x86_64
uv pip install --offline --find-links $(uv cache path)
建议检查您的 uv
版本并按照对应方案操作。如需进一步帮助,可提供 uv --version
输出信息。