error while import pytorch module. (The specified module could not be found.)
Question:
I just newly install python 3.8 via anaconda installer and install pytorch using command
conda install pytorch torchvision cpuonly -c pytorch
when i try to import torch, I got this error message.
OSError: [WinError 126] The specified module could not be found. Error loading "C:Userschuncanaconda3libsite-packagestorchlibasmjit.dll" or one of its dependencies.
I can see dll files are still in the directory.
I ran Dependency Walker and it gave me this result.
I am with this problem for a day.
What should i do if i want to use PyTorch module?
Answers:
Problem solved by downgrade PyTorch version to 1.5.1
I had the same problem, you should check if you installed Microsoft Visual C++ Redistributable, because if you didn’t this may lead to the DLL load failure.
Here is a link to download it: https://aka.ms/vs/16/release/vc_redist.x64.exe
Yeah! As answered by Chiara, Downloading the Microsoft Visual C++ Redistributable solved the issue for me. It mentions that the absence of this package might lead to various Dll Load Failures. Just download the Visual C++ Redistributable file from this link https://aka.ms/vs/16/release/vc_redist.x64.exe and restart your system.
I tried so many different solutions but I couldn’t get PyTorch to work on my main conda environment. So finally I created a new environment and installed PyTorch on it; everything worked on the first try.
I just newly install python 3.8 via anaconda installer and install pytorch using command
conda install pytorch torchvision cpuonly -c pytorch
when i try to import torch, I got this error message.
OSError: [WinError 126] The specified module could not be found. Error loading "C:Userschuncanaconda3libsite-packagestorchlibasmjit.dll" or one of its dependencies.
I can see dll files are still in the directory.
I ran Dependency Walker and it gave me this result.
I am with this problem for a day.
What should i do if i want to use PyTorch module?
Problem solved by downgrade PyTorch version to 1.5.1
I had the same problem, you should check if you installed Microsoft Visual C++ Redistributable, because if you didn’t this may lead to the DLL load failure.
Here is a link to download it: https://aka.ms/vs/16/release/vc_redist.x64.exe
Yeah! As answered by Chiara, Downloading the Microsoft Visual C++ Redistributable solved the issue for me. It mentions that the absence of this package might lead to various Dll Load Failures. Just download the Visual C++ Redistributable file from this link https://aka.ms/vs/16/release/vc_redist.x64.exe and restart your system.
I tried so many different solutions but I couldn’t get PyTorch to work on my main conda environment. So finally I created a new environment and installed PyTorch on it; everything worked on the first try.