Python 2.5 / 2.6 + windows 7 "socket import" dll loading error

I installed the latest 64-bit Python 2.5. I started the shell and try import socket , and we 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 deal? (I checked twice, yes, 64-bit OS).

UPDATE: I also have 32-bit python installed on this computer. If this is a conflict, how can I install both versions of python and are they behaving well?

+4
source share
2 answers

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

It is hard to say exactly why this happened. You may have mistakenly installed 32-bit Python modules. Perhaps there is confusion in the ways.

However, often the easiest way to get around this problem is to switch to 32-bit Python, which works flawlessly on 64-bit Windows. A side benefit is that you sometimes want to use modules that are available only in 32-bit form - support for a 64-bit module is still a bit heterogeneous.

+8
source

This happened to me when I used py2exe to build a (32-bit) binary, and then ran a 64-bit interpreter in the same directory. Apparently (and reasonably) he will select the local instance of the socket module (which then loads the 32-bit dll) through the interpreter's socket module (which correctly loads the 64-bit dll).

0
source

Source: https://habr.com/ru/post/1343484/


All Articles