Can't install pytorch with pip on Windows
Solution 1
The most likely reason for Your issue is a 32-bit installation of python, while the torch libraries rely on having a 64-bit version. I had exactly the same issue.
Just start python
from command line and observe
C:\Users\marci>python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32
My installation now shows 64 bits. If Yours shows 32, then install 64-bit python. I used this link: Official python 64-bit Windows installer
Solution 2
I tried multiple solutions and it wasn't working on Windows 10 until I tried this:
pip install torch==1.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
If you want your GPU enabled then remove the "+CPU":
pip install torch==1.5.0 -f https://download.pytorch.org/whl/torch_stable.html
Solution 3
So you have Cuda 10 installed? If you do, try this:
pip3 install https://download.pytorch.org/whl/cu100/torch-1.2.0-cp37-cp37m-win_amd64.whl
followed by:
pip3 install torchvision
To check if it was installed properly, type this into your command line:
python
followed by:
from __future__ import print_function
import torch
x = torch.rand(5, 3)
print(x)
If you get this output:
tensor([[0.3380, 0.3845, 0.3217],
[0.8337, 0.9050, 0.2650],
[0.2979, 0.7141, 0.9069],
[0.1449, 0.1132, 0.1375],
[0.4675, 0.3947, 0.1426]])
PyTorch was installed correctly!
Solution 4
I had the same issue, and what I noticed is that I was using Python 3.8.1 and the latest PyTorch was for Python 3.7.
I uninstalled Python 3.8.1 and installed 3.7.6 and voila, it worked!
Not sure if this is your case, but it helped me.
Solution 5
pip install torch==1.2.0+cpu torchvision==0.4.0+cpu -f
https://download.pytorch.org/whl/torch_stable.html
Please use this, worked out for me.
Related videos on Youtube
relot
Updated on July 09, 2022Comments
-
relot almost 2 years
I'm trying to install Pytorch with Windows and I'm using the commands of the official site https://pytorch.org/get-started/locally/
pip3 install torch==1.2.0 torchvision==0.4.0 -f https://download.pytorch.org/whl/torch_stable.html
This is the command if I choose Windows, Cuda 10.0, and Python 3.7 But if I run this I get the error message:
ERROR: Could not find a version that satisfies the requirement torch==1.2.0 (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2) ERROR: No matching distribution found for torch==1.2.0
So why does this happen? My pip is version 19.2 and I am in a newly installed python 3.7 environment
-
Admin over 4 yearsI am new in python and was struggling with it. I found Anaconda very useful. Just installed it and then install any library that I want from Anaconda navigator. It is available for all OS. <br> docs.anaconda.com/anaconda/install/windows
-
-
relot over 4 yearsThis doesn't contain torch 1.2 and also not Cuda 10.0
-
Kartograaf over 4 yearsDo you need that version of pytorch? (1.2) Might be easier to install an earlier version that has binaries built for windows. Unfortunately, this happens pretty frequently when using python via windows. Another option is using anaconda.
-
jodag over 4 yearspytorch binaries (e.g. wheel, conda) come prepackaged with cuda so you shouldn't even need cuda installed on the system unless you build from source.
-
theoden over 4 yearsThis answer is incorrect. The definitive way to determine if cuda is working is torch.cuda.is_available(). If it does not return True your code cannot use the GPU, but the above will look exactly the same.
-
arun almost 4 yearstorch 1.5.0 installs fine with python 3.8.3 in Ubuntu, but not in Windows 10. Even with python 3.7 torch 1.5.0 does not install on Win 10.
-
Jortega almost 4 yearsPerfect this solved the install issue for me in Python 3.8
-
Fanchen Bao over 3 yearsThis answer does not address the question.
-
Quinten Cabo over 3 yearsIt does not work for me I get
ERROR: Could not find a version that satisfies the requirement torch==1.5.0+cpu (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2) ERROR: No matching distribution found for torch==1.5.0+cpu
-
yishairasowsky over 2 years@QuintenCabo did you ever solve it? I also couldnt get this to work... thanks!
-
Quinten Cabo over 2 years@yishairasowsky It seemed to be the version of python 32 bit instead of 64 bit. But trying to install it with Conda instead will probably also work better.
-
yishairasowsky over 2 years@QuintenCabo I have 64, and I have tried miniconda. still fails...
-
Quinten Cabo over 2 years@yishairasowsky the python version itself 3.6, 3.7, 3.8 or 3.9 can also matter. Maybe try full conda? I found that with python 3.9 it actually only has really old versions available. But that was a couple months ago. Good luck! Maybe try a different os as well perhaps. Again good luck. These things really suck if they drag out.