【问题标题】:pip - Installing specific package version does not workpip - 安装特定的软件包版本不起作用
【发布时间】:2019-01-22 10:40:11
【问题描述】:

我试图通过pip3 安装一个库 (allennlp)。但它抱怨 PyTorch 版本。虽然allennlp 需要torch=0.4.0 我有torch=0.4.1

...
Collecting torch==0.4.0 (from allennlp)
  Could not find a version that satisfies the requirement torch==0.4.0 (from allennlp) (from versions: 0.1.2, 0.1.2.post1, 0.4.1)
No matching distribution found for torch==0.4.0 (from allennlp)

也可以手动安装:

pip3 install torch==0.4.0

也不行:

  Could not find a version that satisfies the requirement torch==0.4.0 (from versions: 0.1.2, 0.1.2.post1, 0.4.1)
No matching distribution found for torch==0.4.0

其他版本也一样。

Python 是在 Mac OS 上通过 brew 安装的版本 Python 3.7.0

我记得前段时间我可以通过使用pip3 install torch==0.X.X 在版本0.4.00.3.1 之间切换。

我该如何解决这个问题?

【问题讨论】:

    标签: python-3.x pip homebrew pytorch allennlp


    【解决方案1】:

    allennlp master branch specifies torch>=0.4.0,<0.5.0

    最新版本是 v0.6.0 - 仅在大约 3 小时前发布 - 还指定了这个范围:https://github.com/allenai/allennlp/blob/v0.6.0/setup.py#L104

    您可能正在使用固定 torch==0.4.0: https://github.com/allenai/allennlp/blob/v0.5.1/setup.py#L104 的旧版本(可能是 v0.51)

    torch 尚未发布支持 PyPI 3.7 的 v0.4.0 发行版:CPython 2.7、3.5 和 3.6 有 wheels。没有源代码分发。

    allennlp==0.6.0torch==0.4.1post2 应该适用于 Python 3.7。我能够使用我的项目johnnydep 解决 linux/Python 3.7.0 运行时上的(相当大的)依赖树:

    $ johnnydep allennlp --fields name version_latest_in_spec
    name                                         version_latest_in_spec
    -------------------------------------------  ------------------------
    allennlp                                     0.6.0
    ├── awscli>=1.11.91                          1.15.78
    │   ├── PyYAML<=3.13,>=3.10                  3.13
    │   ├── botocore==1.10.77                    1.10.77
    │   │   ├── docutils>=0.10                   0.14
    │   │   ├── jmespath<1.0.0,>=0.7.1           0.9.3
    │   │   └── python-dateutil<3.0.0,>=2.1      2.7.3
    │   │       └── six>=1.5                     1.11.0
    │   ├── colorama<=0.3.9,>=0.2.5              0.3.9
    │   ├── docutils>=0.10                       0.14
    │   ├── rsa<=3.5.0,>=3.1.2                   3.4.2
    │   │   └── pyasn1>=0.1.3                    0.4.4
    │   └── s3transfer<0.2.0,>=0.1.12            0.1.13
    │       └── botocore<2.0.0,>=1.3.0           1.10.77
    │           ├── docutils>=0.10               0.14
    │           ├── jmespath<1.0.0,>=0.7.1       0.9.3
    │           └── python-dateutil<3.0.0,>=2.1  2.7.3
    │               └── six>=1.5                 1.11.0
    ├── cffi==1.11.2                             1.11.2
    │   └── pycparser                            2.18
    ├── conllu==0.11                             0.11
    ├── editdistance                             0.4
    ├── flaky                                    3.4.0
    ├── flask-cors==3.0.3                        3.0.3
    │   ├── Flask>=0.9                           1.0.2
    │   │   ├── Jinja2>=2.10                     2.10
    │   │   │   └── MarkupSafe>=0.23             1.0
    │   │   ├── Werkzeug>=0.14                   0.14.1
    │   │   ├── click>=5.1                       6.7
    │   │   └── itsdangerous>=0.24               0.24
    │   └── Six                                  1.11.0
    ├── flask==0.12.1                            0.12.1
    │   ├── Jinja2>=2.4                          2.10
    │   │   └── MarkupSafe>=0.23                 1.0
    │   ├── Werkzeug>=0.7                        0.14.1
    │   ├── click>=2.0                           6.7
    │   └── itsdangerous>=0.21                   0.24
    ├── gevent==1.3.5                            1.3.5
    │   └── greenlet>=0.4.13                     0.4.14
    ├── h5py                                     2.8.0
    │   ├── numpy>=1.7                           1.15.0
    │   └── six                                  1.11.0
    ├── jsonnet==0.10.0                          0.10.0
    ├── nltk                                     3.3.0
    │   └── six                                  1.11.0
    ├── numpy                                    1.15.0
    ├── numpydoc==0.8.0                          0.8.0
    │   ├── Jinja2>=2.3                          2.10
    │   │   └── MarkupSafe>=0.23                 1.0
    │   └── sphinx>=1.2.3                        1.7.6
    │       ├── Jinja2>=2.3                      2.10
    │       │   └── MarkupSafe>=0.23             1.0
    │       ├── Pygments>=2.0                    2.2.0
    │       ├── alabaster<0.8,>=0.7              0.7.11
    │       ├── babel!=2.0,>=1.3                 2.6.0
    │       │   └── pytz>=0a                     2018.5
    │       ├── docutils>=0.11                   0.14
    │       ├── imagesize                        1.0.0
    │       ├── packaging                        17.1
    │       │   ├── pyparsing>=2.0.2             2.2.0
    │       │   └── six                          1.11.0
    │       ├── requests>=2.0.0                  2.19.1
    │       │   ├── certifi>=2017.4.17           2018.8.13
    │       │   ├── chardet<3.1.0,>=3.0.2        3.0.4
    │       │   ├── idna<2.8,>=2.5               2.7
    │       │   └── urllib3<1.24,>=1.21.1        1.23
    │       ├── setuptools                       40.0.0
    │       ├── six>=1.5                         1.11.0
    │       ├── snowballstemmer>=1.1             1.2.1
    │       └── sphinxcontrib-websupport         1.1.0
    ├── overrides                                1.9
    ├── parsimonious==0.8.0                      0.8.0
    │   └── six>=1.9.0                           1.11.0
    ├── pytest                                   3.7.1
    │   ├── atomicwrites>=1.0                    1.1.5
    │   ├── attrs>=17.4.0                        18.1.0
    │   ├── more-itertools>=4.0.0                4.3.0
    │   │   └── six<2.0.0,>=1.0.0                1.11.0
    │   ├── pluggy>=0.7                          0.7.1
    │   ├── py>=1.5.0                            1.5.4
    │   ├── setuptools                           40.0.0
    │   └── six>=1.10.0                          1.11.0
    ├── pytz==2017.3                             2017.3
    ├── requests>=2.18                           2.19.1
    │   ├── certifi>=2017.4.17                   2018.8.13
    │   ├── chardet<3.1.0,>=3.0.2                3.0.4
    │   ├── idna<2.8,>=2.5                       2.7
    │   └── urllib3<1.24,>=1.21.1                1.23
    ├── responses>=0.7                           0.9.0
    │   ├── cookies                              2.2.1
    │   ├── requests>=2.0                        2.19.1
    │   │   ├── certifi>=2017.4.17               2018.8.13
    │   │   ├── chardet<3.1.0,>=3.0.2            3.0.4
    │   │   ├── idna<2.8,>=2.5                   2.7
    │   │   └── urllib3<1.24,>=1.21.1            1.23
    │   └── six                                  1.11.0
    ├── scikit-learn                             0.19.2
    ├── scipy                                    1.1.0
    │   └── numpy>=1.8.2                         1.15.0
    ├── spacy<2.1,>=2.0                          2.0.12
    │   ├── cymem<1.32,>=1.30                    1.31.2
    │   ├── dill<0.3,>=0.2                       0.2.8.2
    │   ├── murmurhash<0.29,>=0.28               0.28.0
    │   ├── numpy>=1.7                           1.15.0
    │   ├── plac<1.0.0,>=0.9.6                   0.9.6
    │   ├── preshed<2.0.0,>=1.0.0                1.0.1
    │   │   └── cymem<1.32.0,>=1.30              1.31.2
    │   ├── regex==2017.4.5                      2017.4.5
    │   ├── requests<3.0.0,>=2.13.0              2.19.1
    │   │   ├── certifi>=2017.4.17               2018.8.13
    │   │   ├── chardet<3.1.0,>=3.0.2            3.0.4
    │   │   ├── idna<2.8,>=2.5                   2.7
    │   │   └── urllib3<1.24,>=1.21.1            1.23
    │   ├── thinc<6.11.0,>=6.10.3                6.10.3
    │   │   ├── cymem<1.32.0,>=1.30.0            1.31.2
    │   │   ├── cytoolz<0.10,>=0.9.0             0.9.0.1
    │   │   │   └── toolz>=0.8.0                 0.9.0
    │   │   ├── dill<0.3.0,>=0.2.7               0.2.8.2
    │   │   ├── msgpack-numpy<1.0.0,>=0.4.1      0.4.3.1
    │   │   │   ├── msgpack>=0.3.0               0.5.6
    │   │   │   └── numpy>=1.9.0                 1.15.0
    │   │   ├── msgpack<1.0.0,>=0.5.6            0.5.6
    │   │   ├── murmurhash<0.29.0,>=0.28.0       0.28.0
    │   │   ├── numpy>=1.7.0                     1.15.0
    │   │   ├── plac<1.0.0,>=0.9.6               0.9.6
    │   │   ├── preshed<2.0.0,>=1.0.0            1.0.1
    │   │   │   └── cymem<1.32.0,>=1.30          1.31.2
    │   │   ├── six<2.0.0,>=1.10.0               1.11.0
    │   │   ├── tqdm<5.0.0,>=4.10.0              4.24.0
    │   │   └── wrapt<1.11.0,>=1.10.0            1.10.11
    │   └── ujson>=1.35                          1.35
    ├── tensorboardX==1.2                        1.2
    │   ├── numpy                                1.15.0
    │   ├── protobuf>=0.3.2                      3.6.1
    │   │   ├── setuptools                       40.0.0
    │   │   └── six>=1.9                         1.11.0
    │   └── six                                  1.11.0
    ├── torch<0.5.0,>=0.4.0                      0.4.1.post2
    ├── tqdm>=4.19                               4.24.0
    ├── typing                                   3.6.4
    └── unidecode                                1.0.22
    

    【讨论】:

    • 太好了,就是这样!显然,我通过 pip 得到的版本就像你说的固定到 v0.4.0 (我之前得到版本 allennlp==0.5.1)。使用pip3 install git+https://github.com/allenai/allennlp 开箱即用,没有任何问题。非常感谢!
    猜你喜欢
    • 2021-09-16
    • 2012-12-04
    • 2023-01-04
    • 2022-01-17
    • 1970-01-01
    • 2020-08-22
    • 2021-07-31
    相关资源
    最近更新 更多