Abdellah Cheik
Abdellah Cheik

Reputation: 1111

Could not find a version that satisfies the requirement torch>=1.0.0?

Could not find a version that satisfies the requirement torch>=1.0.0 No matching distribution found for torch>=1.0.0 (from stanfordnlp)

Upvotes: 111

Views: 508908

Answers (28)

Vidhan Rathore
Vidhan Rathore

Reputation: 21

I too got this error, If any one of the above solution didn't work then. check your python version it should be between 3.8 to 3.12. Because I was using the 3.13 you just need to uninstall previous version install python version between 3.8 to 3.12.

Upvotes: 2

uniter1010
uniter1010

Reputation: 21

Python version matters!

Python 3.11 installed from microsoft store works fine with CUDA 12.4 and PyTorch stable (2.5.1)

if you currently have python 3.13 (2024-11-17) You will NOT be able to install PyTorch like this:

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124

then you will have an error:

ERROR: Could not find a version that satisfies the requirement torch (from versions: none)
ERROR: No matching distribution found for torch

Upvotes: 2

Lucas
Lucas

Reputation: 1

Transformer + PyTorch often makes trouble on new hardware Most of the time getting the right torch pip command from: https://pytorch.org/ helps

Upvotes: 0

Ashritha Rai
Ashritha Rai

Reputation: 1

Try:

pip install torch

It worked for me.

Upvotes: -2

Ankush Agarwal
Ankush Agarwal

Reputation: 71

There is a issue with python3.12. So, I need to downgrade it to python3.11

brew uninstall python

brew install [email protected]

pip install torch===2.1.0 torchvision===0.16.0 -f https://download.pytorch.org/whl/torch_stable.html

This works fine for me in MacOS.

Upvotes: 7

Antiez
Antiez

Reputation: 947

Running Apple Silicon M3 Pro the only way that worked for me was to load the nightly build as recommended by Apple Developers website:

pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu

It is expected to work with conda as well (Recommended way)

Upvotes: 14

Rajdeep Borgohain
Rajdeep Borgohain

Reputation: 121

If you are having this issue: try to check if you have any issues with apt_pkg,

  • Before downgrading to a lower version, try this command sudo apt install --reinstall python3 python python3-minimal --fix-broken

In my case: I have Python 3.12, error was with apt_pkg

Upvotes: 0

Ricardo Freire
Ricardo Freire

Reputation: 151

I tried to install torch 2.1.0 into Python 3.12.0 and had this same error. It turns out torch doesn't like "the newest python on the block". Downgraded to python 3.11.1 and installation finished successfuly.

Upvotes: 15

Arnaud Moulis
Arnaud Moulis

Reputation: 199

I had some difficulties with this as well. The steps I had to do was:

Install the latest version of PyTorch:

 pip3 install torch===1.3.1 torchvision===0.4.2 -f https://download.pytorch.org/whl/torch_stable.html

Make sure you are installing with 64bit python version; otherwise, it won't work

Upvotes: 19

W Kenny
W Kenny

Reputation: 2069

Try this one, I am using Python 3.6 and I ran this command it works

pip install torch===1.6.0 torchvision===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html

Upvotes: 0

Youcef B
Youcef B

Reputation: 1233

I did follow many suggestions in this thread by installing python 3.7 and python 3.9 ( the one I have by default on my machine is 3.11). The only thing that worked for me is to install the 3.8 version using pyenv and install pytorch from there. Here is the code :

# install python 3.8
pyenv install 3.8

# switch to python 3.8
pyenv shell 3.8

# install pytorch
pip3 install torch torchvision torchaudio

Upvotes: 0

Chatrughan Prasad
Chatrughan Prasad

Reputation: 115

i have installed with python 3.9 version by running below commands:

py -3.9 -m pip install torch

Upvotes: 0

Nishan
Nishan

Reputation: 4421

Use a virtual environment with Python 3.7.9

Go to the python version download page (with binary installers) https://www.python.org/downloads/release/python-379/

Go to that page and download Windows x86-64 embeddable zip file extracted the zip file and placed the contents inside the project folder.

Then used,

virtualenv --python .\python379\python.exe env

To create the virtual environment by specifying the exe location.

Now activate it using .\env\Scripts\activate and you should be able to install.

If you get any error like virtualenv: The term 'virtualenv' is not recognized as a name of a cmdlet, uninstall virtualenv using pip uninstall virtualenv, close the terminal, open terminal as Administrator / root user and install again.

Upvotes: 0

Zahra Golpa
Zahra Golpa

Reputation: 177

I had the same issue with Python 3.8.2 which is currently supported by PyTorch. I updated pip from version 19.2.3 to 22.3.1 and my issue was solved:

pip install --upgrade pip

Upvotes: 0

JoSSte
JoSSte

Reputation: 3372

For people visiting this questions with slightly newer versions of python and pytorch, I had Python 3.8.3 32-bit and even though the pytorch page states that:

Currently, PyTorch on Windows only supports Python 3.7-3.9;

Installing Python 3.9.13 64-bit instead of Python 3.8.3 32-bit solved it for me.
After that, I used the install script generator and ran
python -m pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113
... and it started downloading.

Upvotes: 5

divya teja
divya teja

Reputation: 1

This is for Deep Reinforcement Learning: Chapter-6: 02_dnq_pong.py: I did not verify the above solutions. I found it tedious to change the existing library version.

So, as mentioned by someone in GIT, you just have to change two variables in your loss function. https://github.com/PacktPublishing/Deep-Reinforcement-Learning-Hands-On/issues/90

Change the variables to below: actions_v = torch.tensor(actions).to(device, dtype=torch.int64) done_mask = torch.tensor(dones).to(device, dtype=torch.bool)

You could make similar changes to the variables which cause the error, in your respective programs.

Upvotes: 0

Black Wolf
Black Wolf

Reputation: 41

Use 64-Bit Python. PyTorch doesn't work with 32-Bit Python. I had the same issue.

Upvotes: 4

snowy
snowy

Reputation: 171

I want to pip install " torch>=1.4.0, torchvision>=0.5.0 ", but in a conda env with python=3.0, this is not right. I tried create a new conda env with python=3.7, and pip install " torch>=1.4.0, torchvision>=0.5.0 " again, it is ok.

Upvotes: 0

Slybot
Slybot

Reputation: 598

For previous versions please use the snippets from the PyTorch website; https://pytorch.org/get-started/previous-versions/

As an example, this will turn into an error since the cudatoolkit versions are not listed in pip;

!pip install torch==1.10.0+cu111

ERROR: Could not find a version that satisfies the requirement torch==1.10.0+cu111 (from versions: 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.9.0, 1.9.1, 1.10.0, 1.10.1, 1.10.2, 1.11.0) ERROR: No matching distribution found for torch==1.10.0+cu111

For the same Torch version and cudatoolkit, you can use the following code instead;

!pip install torch==1.10.0+cu111 torchvision==0.11.0+cu111 torchaudio==0.10.0 -f https://download.pytorch.org/whl/torch_stable.html

import torch
TORCH_VERSION = ".".join(torch.__version__.split(".")[:2])
CUDA_VERSION = torch.__version__.split("+")[-1]
print("torch: ", TORCH_VERSION, "; cuda: ", CUDA_VERSION)

Result:

torch:  1.10 ; cuda:  cu111

Upvotes: 0

Vignesh Nandakumar
Vignesh Nandakumar

Reputation: 119

If you have python 3.7 already installed along with newer versions then can use below command to install torch using python 3.7

py -3.7 -m pip install torch

But also note that you have to execute the python program using py -3.7

py -3.7 program_name.py

Upvotes: 3

lorenzomaldini22
lorenzomaldini22

Reputation: 21

I went heaven and earth for this problem and here is what it turned out to be:

1- i had python 3.10 2- the python.exe in my virtual environemnt linked to python310

i uninstalled the python3.10 , then went to delete the paths in system environemnts variables (go to windows search, type this thing, you get a window, click on environment variables, and find a word called paths, click edit) ....\python310\ (i named as such when initially installed, you probs have another name) and also this ...python310\Scripts\

delete them

go to https://www.python.org/downloads/release/python-3711/ , istall pythion 3.7 , after that go back to system env. variables thingy, .. add the paths that ends with ...\python37\ , and ...\python37\Scripts\ (make you sure you end the paths with "")

then go to new command prompt, type python , you should get Python 3.7.0 ...

cd to your virtual environment path script (mine looked like this C:\Users...\python_ver\python_projects\root_environment\Scripts>) , activate to the name of whatever you called, for me i typed: activate tf.

type python again, if you have python 3.7 as a result, you good to go ... if you still seeing python 3.10 ... then you probs get some error saying no python in ....\python310\python.exe ... so:

go the folder that you saved python310 (the path shown in the last step), make sure all folders of your python 3.7 go in there.

type python in cmd in the same virtual envrioment path by the cursor ... to check you running pythong 3.7 ...

once python 3.7 is your default .. run the blood Clot for pytorch https://pytorch.org/ to install pytorch

thanks to all the guys on this

Upvotes: 2

SashimiDélicieux
SashimiDélicieux

Reputation: 475

I finally managed to solve this problem thanks to John Red' comment and serg06 answer. Here's what I've done :

  1. Install Python 3.7.9 and not newer.
  2. BUT make sure to install 64bits python

Every other combination failed for me.

Upvotes: 13

rram12
rram12

Reputation: 61

torch and torchvision need python 3.8.x ... so in your CLI run

python --version

to get the python version. make sure that your environment has python 3.8.x, otherwise, create another virtual environment with anaconda

conda create -n myenv python==3.8 anaconda
conda activate myenv

Then install torch and torchvision by this command

pip install torch===1.5.0 torchvision===0.6.0 -f https://download.pytorch.org/whl/torch_stable.html

Upvotes: 1

serg06
serg06

Reputation: 2695

This can also happen if your Python version is too new. Pytorch currently does not support past 3.7.9.

Figured out from: https://stackoverflow.com/a/58902298/5090928

Upvotes: 167

Sandokan
Sandokan

Reputation: 717

This is the latest command for pytorch.

pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html

Upvotes: 51

R Nanthak
R Nanthak

Reputation: 371

I tried every possible command for Windows, but nothing worked. I also tried using Pycharm package installation, everything throws the same error.

Finally installed Pytorch using Anaconda.

Upvotes: 0

Shiv948
Shiv948

Reputation: 485

follow the link: https://pytorch.org/

and set your system requirement in QUICK START LOCALLY SECTION

enter image description here

Upvotes: -6

Ranjan Sarmah
Ranjan Sarmah

Reputation: 67

I had this same issue while installing standfordnlp in my windows 10 system. Installing torch before installing stanfordnlp worked out for me. I have installed torch from pytorch official website.

Upvotes: 5

Related Questions