Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error while import pytorch module. (The specified module could not be found.)

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:\Users\chunc\anaconda3\lib\site-packages\torch\lib\asmjit.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?

like image 696
Fhun Avatar asked Jul 31 '20 06:07

Fhun


People also ask

Why the specified module could not be found Windows 10?

The specified module could not be found Windows 10 error may be caused by various reasons. In this section, we will briefly show you the reasons that cause the error the specified module could not be found. Missing or corrupted DLL files; Incorrect installation of programs; Outdated Windows drivers; Damaged Windows Registry files; Malware attacks.

What are the import errors for TensorFlow-GPU?

Tensorflow-GPU Installation ImportError: DLL load failed: The specified module could not be found 1 ImportError: DLL load failed: The specified module could not be found. when trying to "from PIL import Image"

How to install PyTorch in Python 3 7?

We have created an environment with name deep7, we use pytorch channel to install pytorch in Python 3.7. After that we activate the environment and test if the import works. If it did you will see no error. To use pytorch, you will have to activate your environment: conda activate deep7 and to deactivate conda deactivate.

What does importerror DLL load failed mean?

ImportError: DLL load failed: The specified module could not be found. During handling of the above exception, another exception occurred: ImportError: DLL load failed: The specified module could not be found.


3 Answers

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

like image 117
Chiara Avatar answered Oct 12 '22 23:10

Chiara


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.

like image 40
Soma Siddhartha Avatar answered Oct 12 '22 23:10

Soma Siddhartha


Problem solved by downgrade PyTorch version to 1.5.1

like image 42
Fhun Avatar answered Oct 13 '22 01:10

Fhun