monir zaman
monir zaman

Reputation: 351

while importing torch- shows - [WinError 126] The specified module could not be found

I have tried to install python torch by using

  !pip install torch 

But I got the error OSError: [WinError 126] The specified module could not be found

Then I tried with

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

The running log is as follows,

enter image description here

Then I have installed the torch by the below command to install the CPU version of the torch.

pip install torch==1.7.1+cpu torchvision==0.8.2+cpu torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html

Then, when I try to test by the command,

import torch
print(torch.__version__)

In the Spyder, it still could not recognize, enter image description here

However, in python.exe it could recognize and provides the correct output.

enter image description here

Upvotes: 1

Views: 4019

Answers (1)

Dwight Foster
Dwight Foster

Reputation: 352

Ok the problem is that you are trying to install the cuda version of Pytorch on a non cuda enabled computer. You can find a similar problem here. You have to download the cpu version of pytorch like this

pip install torch==1.7.1+cpu torchvision==0.8.2+cpu torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html

Upvotes: 1

Related Questions