python26 can't import socket module

Bryan Blackburn blb at
Mon Jun 22 14:24:49 PDT 2009

On Mon, Jun 22, 2009 at 05:01:35PM -0400, Michael Dippery said:
> I recently installed MacPort's python26 port. I am now unable to use  
> Django's script; it fails with the error "Error: cannot import 
> name SSLError" (I have tried with both py25-django and py26-django 
> installed).
> The problem occurs when a piece of Django code tries to access  
> socket.sslerror. I fired up Python 2.6, and got the following error when I 
> tried to "import socket":
> Python 2.6.2 (r262:71600, Jun 22 2009, 15:02:00)
> [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import socket
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ 
> lib/python2.6/", line 64, in <module>
>     from _ssl import SSLError as sslerror
> ImportError: cannot import name SSLError
> The python25 port used to have a py25-socket-ssl port which I believe may 
> have fixed this problem, but, of course, that port no longer exists for 
> python26 (the SSL socket stuff is supposedly included in python26). Is 
> there a reason this doesn't work, and moreover, how do I fix it?

It is included in python26, but it sounds like an issue occurred when it was
being built.  What version of OpenSSL did you have installed and active when
you built python26 (port installed openssl)?  This usually occurs when
python's build system fails to link to OpenSSL, and instead of simply
failing with an error message, it just continues on and doesn't install all
the needed modules.


> =====================
> Michael Dippery
> Systems Programmer
> CEES, Rensselaer Polytechnic Institute
> W: (518) 276-8143
> E: mpd at

More information about the macports-users mailing list