Basic steps that one would follow to have python ibm_db driver installed are:
1. Install and configure required python version
2. Install the python ibm_db driver.
When you try ibm_db installation as a non-root user, it might make use of the in-built(root installation) python and hence installation can fail with error " [Errno 30] Read-only file system".
To overcome the problem, you could either get write permissions for the site-packages directory or can have your own copy of python installed. If you are going to have your own copy of python installation, there are certain per-requisites viz zlib, openssl that you might run into while installing python/using ez_setup.py and chances are that your installation might fail with errors. To have a clean installation, you could try the following:
1. Install zlib
--------------------------------------------------------------------------------------------------------------------------------------------
You can configure your own zlib as follows:
i) download zlib and extract source tar file
$curl -O http://www.zlib.net/zlib-1.2.8.tar.gz
$tar -xzvf zlib-1.2.8.tar.gz
ii) config and install
$./configure --prefix=/Users/regress1/python/zlib128
$make
$make install
2. install openssl:
--------------------------------------------------------------------------------------------------------------------------------------------
i) download oppenssl and extract source tar file
$curl -O http://www.openssl.org/source/openssl-1.0.2e.tar.gz (you can download the version as per your requirement)
$tar -xzvf openssl-1.0.2d.tar.gz
ii) config and install
$cd to open openssl folder
$./Configure darwin64-x86_64-cc --prefix=/Users/regress1/python/openssl
$make
$make install
3. Install Python:
--------------------------------------------------------------------------------------------------------------------------------------------
i) download and extract python
ii) config and install
$CFLAGS="-I/Users/regress1/python/zlib128/include -I/Users/regress1/python/openssl/include" LDFLAGS="-L/Users/regress1/python/zlib128/lib -L/Users/regress1/python/openssl/lib" ./configure --prefix=/Users/regress1/python/python2710
$make
$make install
4. install setuptools
--------------------------------------------------------------------------------------------------------------------------------------------
i) set local python in PATH env variable
$export PATH=/Users/regress1/python/python2710/bin:$PATH
ii) install setuptools using ez_setup script
$curl https://bootstrap.pypa.io/ez_setup.py -o - | python
5. Install valid certificate
---------------------------------------------------------------------------------------------------------------------------------------------
If you hit certificate errors while trying to install the packages from pypi, you would need to make sure you have a valid certificate available under your setuptools directory.
Error one might see would be: ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)
You can install a valid certificate using the following steps:
i) curl http://curl.haxx.se/ca/cacert.pem -o /Users/regress1/python/openssl/ssl/certs/ca-bundle.crt
ii) Unzipp the setuptools under /Users/regress1/python/Python-2.7.10
cd setuptools-18.4/setuptools
edit ssl_support.py and add following line in bold:
cert_paths = """
/Users/regress1/python/openssl/ssl/certs/ca-bundle.crt
/etc/pki/tls/certs/ca-bundle.crt
/etc/ssl/certs/ca-certificates.crt
/usr/share/ssl/certs/ca-bundle.crt
/usr/local/share/certs/ca-root.crt
/etc/ssl/cert.pem
/System/Library/OpenSSL/certs/cert.pem
""".strip().split()
cd ../
iii) python setup.py install (install setup tools to make the changes effective)
6. Install ibm_db :
----------------------------------------------------------------------------------------------------------------------------------------------
i) easy_install ibm_db or pip install ibm_db or pip3 install ibm_db
ii) If you are on MAC OS, you would need to set DYLD_LIBRARY_PATH to the lib path where ODBC and CLI Driver is extracted.
e.g : export DYLD_LIBRARY_PATH=/Users/regress1/python/python2710/lib/python2.7/site-packages/ibm_db-2.0.6-py2.7-macosx-10.4-x86_64.egg/clidriver/lib
7. If you are establishing an SSL connection as a non-root user and installed the ibm_db driver as root, you would need to give necessary permissions to <path to clidriver>/cfg folder, failing which
you might hit error for the connection.
e.g :
#!/usr/bin/env python
import ibm_db
conn = ibm_db.connect(
'UID=uuuuuu;PWD=xxxxxx;DATABASE=BLUDB;HOSTNAME=dashdbxxxxxx.services.dal.bluemix.net;PORT=50001;PROTOCOL=TCPIP;SECURITY=ssl', '', '')
Exception: [IBM][CLI Driver] SQL10013N The specified library "GSKit Error: 8" could not be loaded. SQLSTATE=42724 SQLCODE=-10013
To resolve above error, you could perform the following action:
cd <clidriver path installed as root>
chmod o+w cfg
Tags: 
openssl
zlib
pre-requisites
driver
python
for
ibm_db