'pipenv is unable to find the right package version using pytorch index

I'm confused by how pipenv resolves the available package versions. I specified the index and I clearly see version 0.8.1 in the list on their download site enter image description here

This is my pipenv version. I'm running on Mac OSX and installed pipenv through brew.

~ pipenv --version
pipenv, version 2021.5.29

Pipfile

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

[[source]]
name = "pytorch"
url = "https://download.pytorch.org/whl/torch_stable.html"
verify_ssl = false

[packages]
...
torch = {index="pytorch", version="==1.7.1"}
torchtext = {index="pytorch", version="==0.8.1"}
...

[dev-packages]

[requires]
python_version = "3.7"

The error when I run pipenv install:

Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✘ Locking Failed! 
CRITICAL:pipenv.patched.notpip._internal.index.package_finder:Could not find a version that satisfies the requirement torchtext==0.8.1 (from -r /var/folders/0q/10lqt8nn6_l87q71lx_d233r0000gn/T/pipenv2ix9if8erequirements/pipenv-qm980cdf-constraints.txt (line 7)) (from versions: 0.1.1, 0.2.0, 0.2.1, 0.2.3, 0.3.1, 0.4.0, 0.5.0, 0.6.0)
[ResolutionFailure]:   File "/usr/local/Cellar/pipenv/2021.5.29/libexec/lib/python3.9/site-packages/pipenv/resolver.py", line 741, in _main
...

The error tells me it can't find 0.8.1 and that I can only choose from a super limited set. Why is this? What can I do to fix this?



Solution 1:[1]

You are using the wrong version of Python. It's really that simple.

Read very carefully in the list of library versions in that list:

Torchtext 0.8.1 exists for:

  • cp36m = CPython 3.6m
  • cp37m = CPython 3.7m
  • cp38 = CPython 3.8
  • cp39 = CPython 3.9

You are using: CPython 3.7.

CPython 3.7 (yours) and CPython 3.7m (theirs) is not the same thing.

The "M" stands for a special malloc version of Python which is faster. You can't install an "M" library on a non-"M" Python.

Upgrade to CPython 3.8 or 3.9. I recommend using Pipenv + Pyenv together, which makes it trivial to install different versions of CPython.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mitch McMabers