Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import _socket: "Import Error: DLL load failed"

Tags:

I was attempting to install Django and pymc yesterday. After running into a lot of problems I decided to just re-install Python 2.7. I've done that but am now having problems import almost anything. I get a bunch of lines, the last of which are:

 File "c:\python27\lib\httplib.py", line 71, in <module>    import socket  File "c:\python27\lib\socket.py", line 47, in <module>    import _socket ImportError: DLL load failed: The specified procedure could not be found. 

Whether I run python in the command prompt (which works) and try to do import pip, or type outside of the shell python get-pip.py I get those same last lines.

I should state for the record that I have two versions of python on my machine, one being 2.7, and the other being I THINK 2.6 located in a canopy folder, but that doesn't work either, giving an error message of `ImportError: No module named os". I have my PATH environment variable leading with "c:\python27;c:\python27\scripts".

I've re-installed python a couple times now, and have tried the repair option as well, but to no avail. Anyone have any ideas?

EDIT: It seems that when I uninstalled Python, I neglected to delete the C:\Python27 folder. I uninstalled again, deleted the folder, then reinstalled and it works now. Thanks for the help.

like image 697
user3731928 Avatar asked Jun 11 '14 22:06

user3731928


People also ask

How do you fix DLL load failed the specified module could not be found?

importerror: dll load failed: The specified module could not be found error occurs because of the incompatibilities of Microsoft Visual C++ (Visual Studio) versions. The best way to fix this error (importerror: dll load failed) is to reinstall/ install the Microsoft Visual C++ distribution.

How can I fix Importerror DLL load failed the specified module could not be found in Python 3?

In this case, you should uninstall the library first, then update the pip, and finally install the library again. Besides, if the error occurs, because the module is too new, you can solve the problem by installing the module with a specified version.


1 Answers

I had the same error afters upgrading to python 2.7.12.

To solve it, I did another install into the same directory. Interestingly enough, the installer did not recognize the existing installation. I made sure to check "add python.exe to Path". After that, it worked.

Attempting to install python 2.7.12 again, the installer recognized the existing installation and offered me change/repair/uninstall options.

Update: In retrospective, the reason might have been, that I unintentionally mixed a 32-bit installation with a 64-bit update (or vice versa). Python doesn't seem to install into different directories or use different DLL-names. The installer doesn't warn you either. So after the update, your DLLs are a unhealthy mix of 32 and 64-bit variants.

like image 157
Sascha Avatar answered Sep 29 '22 22:09

Sascha