Reputation: 11
I am getting this error !
Traceback (most recent call last): File "/home/e****/RRR/RRR_Success.py", line 37, in ? import ibm_db ImportError: libdb2.so.1: cannot open shared object file: No such file or directory
Please help me to solve this problem
Upvotes: 1
Views: 7454
Reputation: 4718
This is what I did for a docker image:
WORKDIR /home/db2_cli_odbc_driver
RUN apt-get update && \
apt-get --assume-yes install \
wget && \
wget https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz -O odbc_cli.tar.gz && \
tar -xvf odbc_cli.tar.gz && rm odbc_cli.tar.gz && \
echo /home/db2_cli_odbc_driver/clidriver/lib > /etc/ld.so.conf.d/db2.conf && \
ldconfig && \
apt-get purge -y --auto-remove wget && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV IBM_DB_HOME=/home/db2_cli_odbc_driver/clidriver
In order words,
/etc/ld.so.conf.d/db2.conf
file pointing to the target folderldconfig
IBM_DB_HOME
variable before installing the python packageUpvotes: 1
Reputation: 1683
From my experience LD_LIBRARY_PATH was not needed. I got this problem on a system where the python db2 odbc driver and db2 server were on the same machine.
First check if there is only one libdb2.so.1 file on the system.
find / -name libdb2.so.1
If there are two, chances are they are different, so check the md5sum.
[root@localhost ~]# cat /etc/ld.so.conf.d/db2-odbc.conf
/opt/ibm/db2/odbc_cli/clidriver/lib
[root@localhost ~]# ll /opt/ibm/db2/odbc_cli/clidriver/lib/libdb2.so.1
[root@localhost ~]# ll /home/db2inst1/sqllib/lib64/libdb2.so.1
-r-xr-xr-x 1 bin bin 42685547 Dec 15 08:49 /home/db2inst1/sqllib/lib64/libdb2.so.1
[root@localhost ~]# md5sum /home/db2inst1/sqllib/lib64/libdb2.so.1
ffca929b98201e3934e9625d1480890f /home/db2inst1/sqllib/lib64/libdb2.so.1
[root@localhost ~]# md5sum /opt/ibm/db2/odbc_cli/clidriver/lib/libdb2.so.1
a1247f1582eb1bd2fc248b3901812951 /opt/ibm/db2/odbc_cli/clidriver/lib/libdb2.so.1
[root@localhost ~]#
The files are different, you can control which file is linked by modifying ldconfig.
[root@localhost ~]# ll /etc/ld.so.conf.d/
total 24
-rw-r--r--. 1 root root 17 Feb 9 2012 atlas-x86_64.conf
-rw-r--r-- 1 root root 28 Dec 15 08:50 db2.conf
-rw-r--r-- 1 root root 36 Dec 15 09:07 db2-odbc.conf
-r--r--r--. 1 root root 324 Jun 6 2014 kernel-2.6.32-431.20.3.el6.x86_64.conf
-rw-r--r--. 1 root root 17 Feb 3 2014 mysql-x86_64.conf
-rw-r--r--. 1 root root 22 Jul 18 2011 qt-x86_64.conf
[root@localhost ~]#
I removed the db2.conf file from this folder, and ran ldconfig, it then started to work.
[root@localhost ~]# mv /etc/ld.so.conf.d/db2.conf mahesh/
[root@localhost ~]# ldconfig
Note that the db2 client from db2inst1 still works and this is where the LD_LIBRARY_PATH is set.
[root@localhost ~]# su - db2inst1
[db2inst1@localhost ~]$ db2 connect to dbname
Database Connection Information
Database server = DB2/LINUXX8664 10.5.3
SQL authorization ID = DB2INST1
Local database alias = dbname
[db2inst1@localhost ~]$ env | grep LIBRARY
LD_LIBRARY_PATH=/home/db2inst1/sqllib/lib64:/home/db2inst1/sqllib/lib32
[db2inst1@localhost ~]$
Upvotes: 1
Reputation: 11
Above error indicate DB2 client libraries is not in your LD_LIBRARY_PATH, Please set /home/../path/to/sqllib/lib in your LD_LIBRARY_PATH. For more info you can go through http://www-01.ibm.com/support/knowledgecenter/SSEPGG_10.5.0/com.ibm.db2.luw.apdv.gs.doc/doc/c0006321.html?lang=en
Upvotes: 1