SSL support in Python doesn't always work out the box, especially when using virtualenv.
You'll know you have a problem when you get an error similar to the following:
AttributeError: 'module' object has no attribute 'ssl'
If you are receiving this using your system Python installation, as well as your virtualenv you'll need to follow Patrick Altman's instructions.
However, after completing the above you will find that your system python passes the following quick test:
$ python
>>> import socket
>>> hasattr(socket, "ssl")
True
But your virtualenv:
/path/to/your/virtualenv/source bin/activate
Fails the same test:
$ python
>>> import socket
>>> hasattr(socket, "ssl")
False
It seems that virtualenv has problems picking up ssl settings, especially, in my experience, when openssl is installed after virtualenv. Creating fresh virtual environments has no effect.
To get round the problem, try the following:
Via your system python:
$ python
>>> import _ssl
>>> _ssl.__file__
You should get a path similar to (Do not modify anything in this directory):
/usr/local/lib/python2.5/lib-dynload/_ssl.so
Copy or symlink that to file in your virtualenv python site-packages folder:
cp /usr/local/lib/python2.5/lib-dynload/_ssl.so /path/to/your/virtualenv/lib/python2.5/site-packages/_ssl.so
And it should all work fine now. Test it in your virtualenv via the same command from earlier:
/var/odbody/uat/odbody-uat/source bin/activate
>>> import socket
>>> hasattr(socket, "ssl")
True
I believe this to be a bug in virtualenv and have reported it as such. Although I'd happily be proved otherwise!
(Many thanks to Marius Gedminas in #zope3-dev for his help with this problem)
UPDATE: Impressively quick update from virtualenv's author Ian Bicking. I haven't had a chance to test it yet.