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

pipenv使用pytorch源安装时无法找到torchtext==0.8.1版本问题求助

问题产生原因
  1. 你所使用的2021.5.29版本Pipenv存在已知缺陷:单包指定索引源的配置不生效,即使你给torchtext显式标注了index="pytorch",依赖解析阶段依然只会从默认的PyPI官方源检索版本。而PyPI官方源的torchtext最高仅发布到0.6.0,0.7及以上版本均仅在PyTorch自有源提供,因此触发找不到对应版本的报错。
  2. 你选择的torch 1.7.1 + torchtext 0.8.1 + Python 3.7的版本组合本身没有兼容性问题,PyTorch源也确实存在对应版本安装包,问题完全来自Pipenv的解析逻辑错误。
修复方案

你可以根据自己的使用习惯选择任意一种方法解决:

  • 方法1:临时指定安装源,跳过解析缺陷
    直接执行如下命令安装,无需修改现有配置:
    pipenv install torchtext==0.8.1 --extra-index-url=https://download.pytorch.org/whl/torch_stable.html
    安装完成后会自动更新Pipfile和Pipfile.lock,后续执行pipenv install不会再触发报错。
  • 方法2:调整Pipfile的源优先级
    修改Pipfile中source块的顺序,把PyTorch源放在PyPI源前面,修改后如下:
[[source]]
name = "pytorch"
url = "https://download.pytorch.org/whl/torch_stable.html"
verify_ssl = false

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

修改后删除本地已生成的无效Pipfile.lock(如果存在),重新执行pipenv install即可正常解析。

  • 方法3:升级Pipenv到最新稳定版
    2022年之后发布的Pipenv版本已经修复了单包指定索引不生效的问题,执行brew upgrade pipenv升级后,原有配置不需要做任何修改即可正常使用。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.28 23:27:03