Not Able to Import ibm_db in Python 2.7.4

2,743 views
Skip to first unread message

Akshay Vats

unread,
May 10, 2013, 2:34:44 PM5/10/13
to ibm...@googlegroups.com
Hi,

I have been trying to be able to import ibm_db in my python scripts but had no luck so far. I have tried everything mentioned in other discussions like this one.

Environment:
Windows 7 (64 bit), Python 2.7.4 (32 bit)

Setup steps:
  1. Installed Visual Studio 2008 Professional
  2. Installed 'ibm_data_server_driver_package_win32_v10.1.exe'
  3. Created 'IBM_DB_HOME' system variable with value=C:\Program Files (x86)\IBM\IBM DATA SERVER DRIVER
  4. Created 'LIB' system variable with value=C:\Program Files (x86)\IBM\IBM DATA SERVER DRIVER\bin (this location contains db2cli.dll)
  5. Installed 'distribute 0.6.38' python package (for easy_install)
  6. Installed 'ibm_db-2.0.2-py2.7-win32.egg' using easy_install utility (installation completed successfully without any errors/warnings)
  7. Created 'PYTHONPATH' system variable with value=C:\Python27\Lib\site-packages\ibm_db-2.0.2-py2.7-win32.egg (this location contains ibm_db_dbi.py)

Issue:
When I try to import ibm_db, I encounter an import error.

Command Line Output:
Python 2.7.4 (default, Apr  6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ibm_db
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.

P.S: I don't see any pop ups about which dll is failing (as mentioned here: https://groups.google.com/d/msg/ibm_db/iAdTrZnTmfc/ZiLzgo12txcJ)

I would really appreciate some help since I am in a deadline crunch.

Rahul

unread,
May 10, 2013, 2:55:03 PM5/10/13
to ibm_db
Hi Akshay,
Please set LIB system variable to C:\Program Files
(x86)\IBM\IBM DATA SERVER DRIVER\lib, If you still getting the
errors then please let us know.

Thanks,
Rahul

On May 10, 11:34 pm, Akshay Vats <akkiv...@gmail.com> wrote:
> Hi,
>
> I have been trying to be able to import ibm_db in my python scripts but had
> no luck so far. I have tried everything mentioned in other discussions like
> this one.
>
> Environment:
> Windows 7 (64 bit), Python 2.7.4 (32 bit)
>
> Setup steps:
>
>    1. Installed Visual Studio 2008 Professional
>    2. Installed 'ibm_data_server_driver_package_win32_v10.1.exe'
>    3. Created 'IBM_DB_HOME' system variable with value=C:\Program Files
>    (x86)\IBM\IBM DATA SERVER DRIVER
>    4. Created 'LIB' system variable with value=C:\Program Files
>    (x86)\IBM\IBM DATA SERVER DRIVER\bin (this location contains db2cli.dll)
>    5. Installed 'distribute 0.6.38' python package (for easy_install)
>    6. Installed 'ibm_db-2.0.2-py2.7-win32.egg' using easy_install utility
>    (installation completed successfully without any errors/warnings)
>    7. Created 'PYTHONPATH' system variable with

Akshay Vats

unread,
May 10, 2013, 3:04:51 PM5/10/13
to ibm...@googlegroups.com
Even after setting 'LIB' system variable to 'C:\Program Files (x86)\IBM\IBM DATA SERVER DRIVER\lib' I am getting the same import error.
FYI: This path (C:\Program Files (x86)\IBM\IBM DATA SERVER DRIVER\lib) contains only two files (db2app.lib, db2cli.lib).

Rahul

unread,
May 10, 2013, 3:25:07 PM5/10/13
to ibm_db
check your PATH enviornment variable that it contains C:\Program Files
(x86)\IBM\IBM DATA SERVER DRIVER\bin or not, if not then update the
same.

Akshay Vats

unread,
May 10, 2013, 3:34:35 PM5/10/13
to ibm...@googlegroups.com
PERFECT !!!
Thanks a ton !!!

Alen Huskanovic

unread,
May 16, 2013, 7:01:04 AM5/16/13
to ibm...@googlegroups.com
Hy all,
I have the same problem like Akshay, I followed all steps and I set up environment variables like Akshay, also my PATH  contains C:\Program Files 
(x86)\IBM\IBM DATA SERVER DRIVER\bin but still i got the same error


>>> import ibm_db
Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    import ibm_db
ImportError: DLL load failed: The specified module could not be found.

IBM_DB_HOME=C:\Program Files\ibm\IBM DATA SERVER DRIVER
LIB=C:\Program Files\ibm\IBM DATA SERVER DRIVER\lib
PYTHONPATH=C:\Python27\Lib\site-packages\ibm_db-2.0.2-py2.7-win32.egg

and i use windows 7 64-bit and 32-bit python 2.7.3.

I really appreciate any help you can provide.

Rahul

unread,
May 16, 2013, 7:33:51 AM5/16/13
to ibm_db
Hi Alen,
Have you installed 64-bit DS driver or 32-bit one?
By default 32-bit DS Driver get installed in "..\Program Files
(86)\.." directory but for some of the environment variable you are
setting the DS driver path '..\Program Files\.." which is default
location for 64-bit DS Driver.

Please ensure "C:\Program Files (x86)\IBM\IBM DATA SERVER DRIVER\bin"
should be the path of 32-bit DS Driver, and also check db2cli.dll file
is available here or not.

Thanks,
Rahul

Alen Huskanovic

unread,
May 16, 2013, 8:24:17 AM5/16/13
to ibm...@googlegroups.com
I had installed 64-bit DS driver but now i have 32-bit DS driver, also I changed my environment variables to Program Files(86) and update path. In folder "C:\Program Files(x86)\IBM\IBM DATA SERVER DRIVER\bin" file db2cli.dll  is available. Still i got the same error.

Thanks,
Alen Huskanovic

Rahul

unread,
May 16, 2013, 8:32:44 AM5/16/13
to ibm_db
The 32-bit DS Driver might get installed in different location, could
you check and update your path environment variable with the same. The
error you are getting is looks like 32/64-bit mismatch only.

Thanks,
Rahul

Alen Huskanovic

unread,
May 16, 2013, 8:55:39 AM5/16/13
to ibm...@googlegroups.com
It was installed in default folder but the problem got fixed, I changed LIB from "C:\Program Files (x86)\IBM\IBM DATA SERVER DRIVER\lib" to "C:\Program Files (x86)\IBM\IBM DATA SERVER DRIVER\bin" and succeeded in importing ibm_db.  
Thank You for your time and help,
Alen Huskanovic

Mario Briggs

unread,
May 20, 2013, 1:32:10 PM5/20/13
to ibm_db
I would like to re-iterate that only the PATH env variable needs to be
updated to include the folder where the IBM DB2 ODBC DRIVER .dll
resides (of course this is for windows, for linux the LD_LIBRARY_PATH)
when running the python program.

The LIB env variable comes into the picture only during compilation
(compile time linking).

thanks
Mario
Reply all
Reply to author
Forward
0 new messages