pip - Installing specific package version does not work
I was trying to install a library (allennlp) via pip3. But it complained about the PyTorch version. While allennlp requires torch=0.4.0 I have 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)


Also manually install:

pip3 install torch==0.4.0


Doesn't work either:

  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


Same for other versions.

Python is version Python 3.7.0 installed via brew on Mac OS.

I remember that some time ago I was able to switch between version 0.4.0 and 0.3.1 by using pip3 install torch==0.X.X.

How do I solve this?

allennlp master branch specifies torch&gt;=0.4.0,&lt;0.5.0.  

The latest release is v0.6.0 - released only about 3 hours ago - and also specifies this range: https://github.com/allenai/allennlp/blob/v0.6.0/setup.py#L104

It's possible you are using an older release (probably v0.51) which pinned torch==0.4.0: https://github.com/allenai/allennlp/blob/v0.5.1/setup.py#L104

torch have not yet released a v0.4.0 distribution supporting 3.7 to PyPI: there are wheels for CPython 2.7, 3.5, and 3.6.  No source distributions.

allennlp==0.6.0 and torch==0.4.1post2 should work on Python 3.7. I was able to resolve the (considerably large) dependency tree on a linux/Python 3.7.0 runtime using my project johnnydep:

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

