Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

64-bit python 2.5/2.6+windows 7 "import socket" DLL load error

I installed latest 64-bit Python 2.5. I run the shell, and try to import socket, and get:

>>> import socket
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\python25\lib\socket.py", line 45, in <module>
    import _socket
ImportError: DLL load failed with error code 193

I try the same with 64-bit Python 2.6.6, and get:

>>> import socket
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\python26-64\lib\socket.py", line 46, in <module>
    import _socket
ImportError: DLL load failed: %1 is not a valid Win32 application.

what's the deal? (I double-checked, yes, the OS is 64-bit).

UPDATE: I also have 32-bit python installed on this machine.. if this is a conflict, how can I install both versions of python and have them behave nicely?

like image 990
Claudiu Avatar asked Feb 24 '23 20:02

Claudiu


1 Answers

These two errors are the same error, code 193, reported two different ways. It is caused because your 64 bit Python is trying to load a 32 bit DLL.

It's hard to say exactly why this has happened. Perhaps you installed some 32 bit Python modules by mistake. Perhaps there is some confusion in paths.

However, often the easiest way to get around this sort of problem is to switch to 32 bit Python which runs impeccably on 64 bit Windows. A side benefit is that you will sometimes want to use modules that are only available in 32 bit form – 64 bit module support is still a little patchy.

like image 150
David Heffernan Avatar answered Feb 27 '23 15:02

David Heffernan