python - 无法通过 windows 中的诗歌安装 torchvision
问题描述
感谢Poetry 和 PyTorch的回答,我成功安装了 pytorch 。
但是,我仍然无法通过诗歌安装 torchvision。
> poetry add torchvision==0.8.2
Updating dependencies
Resolving dependencies...
Writing lock file
Package operations: 1 install, 0 updates, 0 removals
• Installing torchvision (0.8.2)
RuntimeError
Unable to find installation candidates for torchvision (0.8.2)
at ~\.poetry\lib\poetry\installation\chooser.py:72 in choose_for
68│
69│ links.append(link)
70│
71│ if not links:
→ 72│ raise RuntimeError(
73│ "Unable to find installation candidates for {}".format(package)
74│ )
75│
76│ # Get the best link
Failed to add packages, reverting the pyproject.toml file to its original content.
我用谷歌搜索了一些答案,上面写着“只是pip install torchvision
”。但我怀疑它是否有效,因为根据 PyPi(https://pypi.org/project/torchvision/#files),Windows 没有轮文件。我尝试了它,但它失败了,正如我所料。
有什么方法可以在 Windows 中安装与最新的 torch(1.7.1) 兼容的最新的 torchvisin?+ 通过诗歌?
解决方案
- 在https://download.pytorch.org/whl/torch_stable.html中查找您要安装的版本(torchvision 版本、python 版本、CUDA 版本、操作系统等)
- 将 URL 依赖项添加到您的
pyproject.toml
文件中。例如,我的依赖项中有 torchvision 1.8.0 使用以下内容
[tool.poetry.dependencies]
python = "^3.8"
torch = {url = "https://download.pytorch.org/whl/cu102/torch-1.8.0-cp38-cp38-win_amd64.whl"}
torchvision = {url = "https://download.pytorch.org/whl/cu102/torchvision-0.9.0-cp38-cp38-win_amd64.whl"}
- 从您激活的虚拟环境中
poetry update torchvision
,您应该一切顺利。
推荐阅读
- excel - 范围的 VBA 代码问题。我收到类型不匹配错误 13
- python - 当我尝试将 csv 数据帧中的列添加到在 pandas 上打开的现有数据帧中时,为什么我不断得到“Nan”值?
- reactjs - 如何使飞行物体反应组件使用gif?
- ios - 如何在 .ics 文件中快速创建 iCal 事件和下载/导出事件。我想要在我的 iPhone 文件中的文件
- google-apps-script - Google Apps 脚本:UrlFetchApp 出现 403 错误
- javascript - 如何突出显示使用 MorphDom 更新的元素?
- javascript - 是否有 React 高阶组件来替换 someData.map(functionReturningComponent)?
- javascript - 克隆内部带有函数的对象
- html - grid-template-areas 生成的行数比预期的多
- javascript - 如何使用页面重新加载 React 设置选择选项?