Thursday, January 12, 2012

Installing ssl for Python (RedHat/CentOS)

Recently, I had to install pythons SSL library (http://docs.python.org/dev/library/ssl.html). 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/test_ssl.py', 'wb') {} 

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


wget http://pypi.python.org/packages/source/s/ssl/ssl-1.15.tar.gz#md5=81ea8a1175e437b4c769ae65b3290e0c

 and Install the module by hand :

tar -xzvf ssl-1.15.tar.gz
cd ssl-1.15
sudo python setup.py 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/__init__.py", 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 setup.py install)

    ReplyDelete