Python 2.7 import socket urllib fails to load, module not found

Emile van Sebille emile at fenx.com
Fri Aug 17 16:57:09 EDT 2012


On 8/17/2012 1:41 PM wdtate at comcast.net said...
>>From cmd prompt - I get this:
> Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import urllib
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
>    File "C:\Python27\lib\urllib.py", line 26, in <module>
>      import socket
>    File "C:\Python27\lib\socket.py", line 47, in <module>
>      import _socket
> ImportError: DLL load failed: The specified module could not be found
>
> I also get that if I attempt to import socket.
>
> NOTE this does not happen when I'm in the pythonwin IDE.
>



So, try the following in both environments:

     import sys
     for ii in sys.path: print ii

You'll likely find diffferences between the two.


In the pythonwin environment, try:

     import socket
     print socket.__file__


Chances are the __file__'s directory isn't in the command line's sys.path.

Emile







More information about the Python-list mailing list