首页 > 解决方案 > 在使用 Pycharm 的 windows 中使用 pipenv 安装 flair 和 pytorch 时发生错误

问题描述

我在安装 python 包flairpytorchvia时遇到问题,pipenv并且还不能解决这个问题。由于我正在尝试使用Pipfile + Pipfile.lock而不是requirements.txt这对我的 python git 存储库进行版本控制,因此目前是不可能的:

pipenv install flair

ERROR: Could not find a version that satisfies the requirement torch>=1.1.0 (from flair->-r c:\users\user.name\appdata\local\temp\pipenv-plyx3uwp-requirements\pipenv-xh_afa_r-requirement.txt (line 1)) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2) ERROR: No matching distribution found for torch>=1.1.0 (from flair->-r c:\users\user.name\appdata\local\temp\pipenv-plyx3uwp-requirements\pipenv-xh_afa_r-requirement.txt (line 1)) Installation Failed

我尝试了这些安装变体torchvision

pipenv install torchvision

安装torchvision应该选择最新的火炬版本

pipenv install torch==1.3

安装手电筒

pipenv install https://download.pytorch.org/whl/cu92/torch-0.4.1-cp37-cp37m-win_amd64.whl

安装 Torch 的替代方法(这里有更多二进制文件: https ://pytorch.org/get-started/previous-versions/#windows-binaries )

pipenv install git+https://github.com/pytorch/vision#egg=torchvision

另一种替代方式,

错误文本:收集 torchvision
  下载 torchvision-0.5.0-cp37-cp37m-win_amd64.whl (1.2 MB)
收集 numpy
  使用缓存的 numpy-1.18.5-cp37-cp37m-win_amd64.whl (12.7 MB)
采集枕>=4.1.1
  下载 Pillow-7.1.2-cp37-cp37m-win_amd64.whl (2.0 MB)
收集六个
  下载 6-1.15.0-py2.py3-none-any.whl (10 kB)

pipenv install torchvision

users\user.name\appdata\local\temp\pipenv-hf2be0xq-requirements\pipenv-57akhz4j-requirement.txt(行
1))(来自版本:0.1.2、0.1.2.post1、0.1.2.post2)
错误:未找到 torch==1.4.0 的匹配分布(来自 torchvision->-rc:\users\user.name\appdat
a\local\temp\pipenv-hf2be0xq-requirements\pipenv-57akhz4j-requirement.txt(第 1 行)
安装失败

安装 torchvision 的唯一方法是没有它的依赖包:

pipenv run pip install --no-deps torchvision

但这并没有解决通过 pipenv 安装 flair 的问题,因为需要依赖项。

标签: pythonpytorchpipenvpipfileflair

解决方案


尝试先清理 Pipfile 和虚拟环境。它看起来像传递依赖和在 Pipfile 中声明的依赖冲突。

然后尝试像这样安装torchvision:

pipenv install torchvision 

这将安装最新的 torchvision 版本和兼容的 torch 版本:

来源

torch   torchvision     python
master / nightly    master / nightly    >=3.6
1.5.0   0.6.0   >=3.5
1.4.0   0.5.0   ==2.7, >=3.5, <=3.8
1.3.1   0.4.2   ==2.7, >=3.5, <=3.7
1.3.0   0.4.1   ==2.7, >=3.5, <=3.7
1.2.0   0.4.0   ==2.7, >=3.5, <=3.7
1.1.0   0.3.0   ==2.7, >=3.5, <=3.7
<=1.0.1     0.2.2   ==2.7, >=3.5, <=3.7

Flair 与 Pytorch 1.1+ 一起使用,如下所述

该项目基于 PyTorch 1.1+ 和 Python 3.6+,因为方法签名和类型提示很漂亮。

安装torchvision后继续安装flair:

pipenv install flair

在这里你可以找到一个工作的 Pipfile 和 Pipfile.lock 文件,这两个操作结束后:

点文件

名称=“pypi”
url = "https://pypi.org/simple"
verify_ssl = 真

[开发包]

[包]
火炬视觉 = "*"
天赋=“*”

[要求]
python_version = "3.6"

Pipfile.lock


推荐阅读