47

Used the install guide on pytorch.org on how to install it and the command I'm using is

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

But it's coming up with this error;

ERROR: Could not find a version that satisfies the requirement torch===1.4.0 (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)

ERROR: No matching distribution found for torch===1.4.0

Is this even a me-related issue? Can other people use this command?

Pip is installed and works for other modules, Python 3.8, CUDA version 10.1, Windows 10 Home 2004

2
  • Maybe add the full output of the command, there might be something meaningful in there. Commented Feb 9, 2020 at 18:59
  • can one not have torch be installed inside the setup.py file when installing my projects i.e. me not having to run pip install torch etc etc? Commented Dec 9, 2021 at 19:15

15 Answers 15

33

Looks like this issue is related to virtual environment. Did you try recommended installation line in another/new one virtual environment? If it doesn't help the possible solution might be installing package using direct link to PyTorch and TorchVision builds for your system:

Windows:

pip install https://download.pytorch.org/whl/cu101/torch-1.4.0-cp38-cp38-win_amd64.whl

pip install https://download.pytorch.org/whl/cu101/torchvision-0.5.0-cp38-cp38-win_amd64.whl

Ubuntu (Linux):

pip install https://download.pytorch.org/whl/cu101/torch-1.4.0-cp38-cp38-linux_x86_64.whl

pip install https://download.pytorch.org/whl/cu101/torchvision-0.5.0-cp38-cp38-linux_x86_64.whl
Sign up to request clarification or add additional context in comments.

3 Comments

i had to -f it like this answer stackoverflow.com/a/59920239/2062726
can one not have torch be installed inside the setup.py file when installing my projects i.e. me not having to run pip install torch etc etc?
what about macos??
23

In the future, I would recommend using the installation widget on the PyTorch website.

It fixed this issue for me by extending the command with -f as follows:

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

3 Comments

Thanks William! If I want to included it in requirements.txt how can I include url part?
can one not have torch be installed inside the setup.py file when installing my projects i.e. me not having to run pip install torch etc etc?
@haneulkim hmm... I'm not sure how the URL can be included in requirements.txt
13

I had same problem and python -m pip install --upgrade pip setuptools wheel worked for me and https://packaging.python.org/tutorials/installing-packages/ may be useful for some package installation problems.

Comments

9

check your python version, my version is python 3.8.2 and it can't find a torch version matched the py version. And I use a 3.7.6 now, I suppose the version below 3.8 would be fine

1 Comment

2023 update if you try to install in Docker (CPU) , image that worked for me was python:3.8.17-slim after a RUN pip install --upgrade pip setuptools wheel, command to install torch was taken from official website => RUN pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
8

I tried pip, only got it working with conda

conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=10.1 -c pytorch

1 Comment

Is Conda preferable over Pip?
3

This is an old one, but it came up when searching for today's problems upgrading torch to 1.12.0. Same kinds of error messages, none of these or other proposals helped. What did help was upgrading pip (now 22.1.2), I was behind a minor release and had been ignoring that. Everything just worked after that.

Comments

3

I also had same problem as a comment up and I decieded it so

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

@Collin TNX!

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
2

For me, the issue was the Python version I was using was unsupported. I was trying to install torch 1.10.0 on Python 3.10.6 which was giving me the same error. Solution was to downgrade Python to 3.8.x

Comments

1

Update 2024

I tried @trsvchn answer, but the links didn't work for me, here is a workaround that I found.

First for torch version 1.4.0 (Note: you can select your desired version)

  1. Open the following link: https://download.pytorch.org/whl/torch/
  2. Download the installer that suits your requirements.
  3. Then run the following command : pip install (location of downloaded file)

For example

pip install C:/Users/dev/Downloads/torch-1.4.0+cpu-cp36-cp36m-win_amd64.whl

Next for torchvision version 0.5.0

  1. Open the following link: https://download.pytorch.org/whl/torchvision/
  2. Repeat steps 2 & 3.

For example

pip install C:/Users/dev/Downloads/torchvision-0.5.0+cpu-cp36-cp36m-win_amd64.whl

Note the cpXX is your Python version, for example, the Python version I was using was 3.6 and I was running a 64-bit machine, so these were the installers that I downloaded.

torch-1.4.0+cpu-cp36-cp36m-win_amd64.whl

torchvision-0.5.0+cpu-cp36-cp36m-win_amd64.whl

Comments

0

I found the right solution that could solve this issue:

Reinstall pytorch from here: https://pytorch.org/get-started/locally/#mac-package-manager

Make sure the torch version is 1.4.0 if it's not run the following command:

pip install syft -f https://download.pytorch.org/whl/torch_stable.html

Now, you can download syft successfully:

pip install syft

to check the version of packages: conda list

Comments

0

In my case I was trying to build image for linux architecture and after I change docker command it worked:

docker buildx build --platform=linux/amd64 -t rahul86s/rsharmp12_model:latest .

Comments

0

I had the same Problem. For me the only Nightly version worked. You can install it with

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

Comments

-1

It could be a syntax issue, because you are using === instead of == in your pip install command.

Comments

-1

In my case, its reason was related compiled version (32/64) I have installed a 32bit version but PyTorch's wheel only provides a 64bit version.

No problem on your command check python version and reinstall the 64bit version.

Comments

-2

I faced the same issue, according to https://pytorch.org/ the best option is to install everything via conda:

conda install pytorch torchvision cudatoolkit=10.2 -c pytorch

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.