简体   繁体   English

在 windows 和 Pycharm 中安装 flair 和 pytorch 时发生错误

[英]An error occured while installing flair and pytorch with pipenv in windows with Pycharm

I am having problems installing the python packages flair and pytorch via pipenv and have not been able to resolve this issue yet.我在通过pipenv安装 python 包flairpytorch时遇到问题,并且还不能解决这个问题。 Since I am trying to version my python git repository with Pipfile + Pipfile.lock instead of requirements.txt this is currently not possible:由于我正在尝试使用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

I tried these variants of installing torchvision :我尝试了安装torchvision的这些变体:

pipenv install torchvision

to install torchvision which should pick up the latest torch version安装torchvision应该选择最新的torch版本

pipenv install torch==1.3

to install torch安装手电筒

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

alternative way to install torch (here is more binaries: https://pytorch.org/get-started/previous-versions/#windows-binaries )安装torch的替代方法(这里有更多二进制文件: https://pytorch.org/get-started/previous-versions/#windows-binaries

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

Another alternative way,另一种替代方式,

Error text: Collecting torchvision
  Downloading torchvision-0.5.0-cp37-cp37m-win_amd64.whl (1.2 MB)
Collecting numpy
  Using cached numpy-1.18.5-cp37-cp37m-win_amd64.whl (12.7 MB)
Collecting pillow>=4.1.1
  Downloading Pillow-7.1.2-cp37-cp37m-win_amd64.whl (2.0 MB)
Collecting six
  Downloading six-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 (line
1)) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
ERROR: No matching distribution found for torch==1.4.0 (from torchvision->-r c:\users\user.name\appdat
a\local\temp\pipenv-hf2be0xq-requirements\pipenv-57akhz4j-requirement.txt (line 1))
Installation Failed

The only way it was possible to install torchvision was without its dependent packages:安装 torchvision 的唯一方法是没有它的依赖包:

pipenv run pip install --no-deps torchvision

But this did not resolve the problem of installing flair via pipenv since the dependencies are needed.但这并没有解决通过 pipenv 安装 flair 的问题,因为需要依赖项。

Try to cleanup the Pipfile and the virtual environment first.尝试先清理 Pipfile 和虚拟环境。 It looks like the transitive dependencies and the ones declared in the Pipfile clash.它看起来像传递依赖和在 Pipfile 中声明的依赖冲突。

Then try to install torchvision like this:然后尝试像这样安装torchvision:

pipenv install torchvision 

This will install the latest torchvision version and the compatible torch version:这将安装最新的 torchvision 版本和兼容的 torch 版本:

Source :来源

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 works with Pytorch 1.1+ as stated here : Flair 与 Pytorch 1.1+一起使用,如下所述:

The project is based on PyTorch 1.1+ and Python 3.6+, because method signatures and type hints are beautiful.该项目基于 PyTorch 1.1+ 和 Python 3.6+,因为方法签名和类型提示很漂亮。

After installing torchvision proceed to install flair:安装torchvision后继续安装flair:

pipenv install flair

Here you can find a working Pipfile and Pipfile.lock file, after the two operations were concluded:在这里你可以找到一个工作的 Pipfile 和 Pipfile.lock 文件,这两个操作结束后:

Pipfile点文件

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

[dev-packages]

[packages]
torchvision = "*" 
flair = "*"

[requires]
python_version = "3.6"

Pipfile.lock Pipfile.lock

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM