Thursday, January 12, 2012

Installing ssl for Python (RedHat/CentOS)

Recently, I had to install pythons SSL library ( After installing the OpenSSL dev Library with YUM I thought to be a good Idea to use easy_install and received following error message:

error: Setup script exited with error: SandboxViolation: open('/usr/lib64/python2.4/test/', 'wb') {} 

After a few minutes of thinking, I decided to download the source with


 and Install the module by hand :

tar -xzvf ssl-1.15.tar.gz
cd ssl-1.15
sudo python install

Confident that this will Install the package I started up python and imported the ssl library just to receive following :

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "ssl/", line 61, in ?
    import _ssl2             # if we can't import it, let the error propagate
ImportError: No module named _ssl2

Now, what the .....?
After a bit of google research I found out that something is not right with the compiled __init__.pyc and deleted the file:

sudo rm /usr/lib64/python2.4/site-packages/ssl/__init__.pyc

And here we go! From now on the ssl library should work just fine.

1 comment:

  1. Had same issue, only thing is needed to be done is cd to another dir after installing, otherwise python trying to load local ssh version.
    (one that remains after install)