Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyTorch installation with pipenv fails (pipenv install torch) #4422

Closed
Alon-Retispec opened this issue Aug 12, 2020 · 11 comments
Closed

PyTorch installation with pipenv fails (pipenv install torch) #4422

Alon-Retispec opened this issue Aug 12, 2020 · 11 comments
Labels

Comments

@Alon-Retispec
Copy link

Alon-Retispec commented Aug 12, 2020

Installing torch fails with error

Trying to install PyTorch on Win10 64bit, Python 3.8.5 64bit, doing either:
pipenv install torch -> fails
or
pipenv install torch===1.6.0 -> fails

However, pip install torch===1.6.0 works great!

Expected result

Describe what you expected.

Actual result

pipenv install torch===1.6.0
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. Y
ou can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Installing torch===1.6.0…
Adding torch to Pipfile's [packages]…
Installation Succeeded
Pipfile.lock (c14e35) out of date, updating to (023c79)…
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 torch===1.6.0 (from -r C:\AppData\Local
\Temp\pipenvh5ftboijrequirements\pipenv-l9xes5ab-constraints.txt (line 2)) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
[ResolutionFailure]: File "c:/users/alon/appdata/local/programs/python/python38/lib/site-packages/pipenv/resolver.py", line 785, in _main
[ResolutionFailure]: resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages)
[ResolutionFailure]: File "c:/users/alon/appdata/local/programs/python/python38/lib/site-packages/pipenv/resolver.py", line 746, in resolve_packages
[ResolutionFailure]: results, resolver = resolve(
[ResolutionFailure]: File "c:/users/alon/appdata/local/programs/python/python38/lib/site-packages/pipenv/resolver.py", line 728, in resolve
[ResolutionFailure]: return resolve_deps(
[ResolutionFailure]: File "c:\appdata\local\programs\python\python38\lib\site-packages\pipenv\utils.py", line 1378, in resolve_deps
[ResolutionFailure]: results, hashes, markers_lookup, resolver, skipped = actually_resolve_deps(
[ResolutionFailure]: File "c:\appdata\local\programs\python\python38\lib\site-packages\pipenv\utils.py", line 1093, in actually_resolve_deps
[ResolutionFailure]: resolver.resolve()
[ResolutionFailure]: File "c:\appdata\local\programs\python\python38\lib\site-packages\pipenv\utils.py", line 818, in resolve
[ResolutionFailure]: raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: No matching distribution found for torch===1.6.0 (from -r C:\AppData\Local\Temp\pipenvh5ftboijrequirements\pipenv-l9xes5ab-constraints.txt (line 2))

Steps to replicate

run: pipenv install torch===1.6.0


pipenv --support | clip
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. Y
ou can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.

@frostming
Copy link
Contributor

However, pip install torch===1.6.0 works great!

It doesn't, can you show the success output? PyTorch doesn't have any wheels for windows since >0.1.2 so it is expected to fail.

@Alon-Retispec
Copy link
Author

However, pip install torch===1.6.0 works great!

It doesn't, can you show the success output? PyTorch doesn't have any wheels for windows since >0.1.2 so it is expected to fail.

Apologies. I was trying to reduce the example to a minimal set of steps and broke it. The line that works in windows is
pip install torch===1.6.0 torchvision===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
What doesn't work is
pipenv install torch===1.6.0 torchvision===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
The output follows:

pipenv install torch===1.6.0 torchvision===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
Creating a virtualenv for this project…
Pipfile: C:\Users\alon\Pipfile
Using C:/Users/alon/AppData/Local/Programs/Python/Python38/python.exe (3.8.5) to create virtualenv…
[=   ] Creating virtual environment...created virtual environment CPython3.8.5.final.0-64 in 2199ms
  creator CPython3Windows(dest=C:\Users\alon\.virtualenvs\alon-3LBCK0RT, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\alon\AppData\Local\pypa\virtualenv)
    added seed packages: pip==20.2.1, setuptools==49.2.1, wheel==0.34.2
  activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

Successfully created virtual environment!
Virtualenv location: C:\Users\alon\.virtualenvs\alon-3LBCK0RT
Creating a Pipfile for this project…
Installing torch===1.6.0…
Error:  An error occurred while installing torch===1.6.0!
Error text:
ERROR: Could not find a version that satisfies the requirement torch===1.6.0 (from -r c:\users\alon\appdata\local\temp\pipenv-gbod9sil-requirements\pipenv-wmtz1vrj-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.6.0 (from -r c:\users\alon\appdata\local\temp\pipenv-gbod9sil-requirements\pipenv-wmtz1vrj-requirement.txt (line 1))

Installation Failed

It might be expected and not a bug, but I thought that the premise is that pipenv supports pip and I assumed I could simply interchange pip for pipenv

@frostming
Copy link
Contributor

frostming commented Aug 13, 2020

Pipenv and pip don't work the same way. Try this Pipfile

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

[packages]
torch = {index = "pytorch",version = "==1.6.0"}

@Alon-Retispec
Copy link
Author

It fails:

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 torch==1.6.0 (from -r C:\Users\alon\AppData\Local\Temp\pipenvw_ws6hharequirements\pipenv-9v1pq3ki-constraints.txt (line 3)) (from versions: none)
[ResolutionFailure]:   File "c:/users/alon/appdata/local/programs/python/python38/lib/site-packages/pipenv/resolver.py", line 785, in _main
[ResolutionFailure]:       resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages)
[ResolutionFailure]:   File "c:/users/alon/appdata/local/programs/python/python38/lib/site-packages/pipenv/resolver.py", line 746, in resolve_packages
[ResolutionFailure]:       results, resolver = resolve(
[ResolutionFailure]:   File "c:/users/alon/appdata/local/programs/python/python38/lib/site-packages/pipenv/resolver.py", line 728, in resolve
[ResolutionFailure]:       return resolve_deps(
[ResolutionFailure]:   File "c:\users\alon\appdata\local\programs\python\python38\lib\site-packages\pipenv\utils.py", line 1378, in resolve_deps
[ResolutionFailure]:       results, hashes, markers_lookup, resolver, skipped = actually_resolve_deps(
[ResolutionFailure]:   File "c:\users\alon\appdata\local\programs\python\python38\lib\site-packages\pipenv\utils.py", line 1093, in actually_resolve_deps
[ResolutionFailure]:       resolver.resolve()
[ResolutionFailure]:   File "c:\users\alon\appdata\local\programs\python\python38\lib\site-packages\pipenv\utils.py", line 818, in resolve
[ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: No matching distribution found for torch==1.6.0 (from -r C:\Users\alon\AppData\Local\Temp\pipenvw_ws6hharequirements\pipenv-9v1pq3ki-constraints.txt (line 3))

@Alon-Retispec
Copy link
Author

Well, it's less elegant but the way to do it is by going to the url at https://download.pytorch.org/whl/torch_stable.html and manually finding the relevant version for your system (in my case cu102/torch-1.6.0-cp38-cp38-win_amd64.whl).
Then either running:
pipenv install https://download.pytorch.org/whl/cu102/torch-1.6.0-cp38-cp38-win_amd64.whl
Or using the pipfile:

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

[dev-packages]

[packages]
torch = {file = "https://download.pytorch.org/whl/cu102/torch-1.6.0-cp38-cp38-win_amd64.whl"}

@cyril4j
Copy link

cyril4j commented Jan 12, 2021

Is there a supported wheel for macos?

I tried a few of the macosx files on download.pytorch.org and I get this error:

[pipenv.exceptions.InstallError]: ERROR: torch-1.7.0-cp38-none-macosx_11_0_x86_64.whl is not a supported wheel on this platform.

@yuijim
Copy link

yuijim commented May 2, 2021

I'm not sure if anyone else will find this useful, but when trying to install CPU torch version this worked for me:

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

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

[packages]
torch = {version = "==1.8.1", index = "pytorch"}
torchvision = {version = "==0.9.1", index = "pytorch"}
torchaudio = {version = "==0.8.1", index = "pytorch"}
Pillow = "*"

[dev-packages]

[requires]
python_version = "3.8"

Notice the cpu in https://download.pytorch.org/whl/cpu/torch_stable.html and NO +cpu in pinned versions (I guess that way unpinned would work too, but haven't checked).

@davelee1030
Copy link

export SYSTEM_VERSION_COMPAT=1 worked for me.
Basically I tried this for numpy, but after that "pipenv install torch" also worked.

@mcps5601
Copy link

This worked for me.

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

[packages]
torch = {file = "https://download.pytorch.org/whl/cu110/torch-1.7.0%2Bcu110-cp38-cp38-linux_x86_64.whl"}

[dev-packages]

[requires]
python_version = "3.8"

For me, I wanted to install CUDA11.0 version of PyTorch.
First, I went to this page.
And then I pasted the download link to the [packages] in Pipfile after copying the link which I wanted to install.

@sup3rcow
Copy link

I had similar "error" with instaling any package from my private repo (pypiserver).

This was solution for me:
I first had to set environment variable

export PIPENV_IGNORE_VIRTUALENVS=1

and than install some package

pipenv install package_name==x.x.x

@Arcitec
Copy link

Arcitec commented Feb 19, 2022

Solved: This is how to install Torch CORRECTLY in Pipenv. Most people do this incorrectly even in various "solutions" I've seen from other people (such as the posts above; EVERY solution above is WRONG and it would be good to clean up those wrong solutions so that we don't mislead people who jump in here from Google)... Well, I've researched to the bottom of this problem and found out the real, intentional solution that everyone should use:

#4961 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants