ibmdb/python-ibmdb

ibm_db module could not be found

chrisstephens1 opened this issue · 5 comments

  • Operating System Name: Win11

  • db2level output from clidriver if in use:

  • Target Db2 Server Version: 11.5.8

  • Python Version: 3.10

  • ibm_db version: 3.2.1

  • For non-Windows, output of below commands:
    uname
    uname -m

  • Value of below environment variables if set:
    IBM_DB_HOME: C:/Users/######/clidriver
    PATH:
    LIB/LD_LIBRARY_PATH/DYLD_LIBRARY_PATH:

  • Test script to reproduce the problem.

  • import ibm_db_dbi as db2

  • For installation related issue, complete output of pip install ibm_db command.

(venv) PS C:\Users########\PycharmProjects\IBM_QMX> pip install ibm_db
Collecting ibm_db
Obtaining dependency information for ibm_db from https://files.pythonhosted.org/packages/7d/4c/3f893a06c63b51f53cb581dee8eab41df9cd6477279b33580ae3fe6e29b3/ibm_db-3.2.1-cp310-cp310-win_amd64.whl.metadata
Using cached ibm_db-3.2.1-cp310-cp310-win_amd64.whl.metadata (1.4 kB)
Using cached ibm_db-3.2.1-cp310-cp310-win_amd64.whl (27.7 MB)
Installing collected packages: ibm_db
Successfully installed ibm_db-3.2.1

Steps to Reproduce:

I am trying to import ibm_db_dbi into my code, and am being met with the following error. I have included the output from installing ibm_db if it's helpful. I also don't see ibm_db listed in the packages in my install. If I go back to version 3.1.4 the ibm_db module is being included.

Traceback (most recent call last):
File "C:\Users\7J3852897\PycharmProjects\IBM_QMX\db2_connect.py", line 1, in
import ibm_db_dbi as db2
File "C:\Users\7J3852897\PycharmProjects\IBM_QMX\venv\lib\site-packages\ibm_db_dbi.py", line 45, in
import ibm_db
ImportError: DLL load failed while importing ibm_db: The specified module could not be found.

@chrisstephens1 Please run the below line before import ibm_db.
import os
os.add_dll_directory('path to clidriver installation until bin')
import ibm_db

Thank you

Bah sorry, that was in the directions and I completely missed it.

I did that and am getting a different error, can you confirm this is not part of the code?

Unable to connect: [IBM][CLI Driver] SQL1109N The command was not processed because the database manager failed to load the following DLL: "GSKit Error: 2". SQLSTATE=42724 SQLCODE=-1109

GSKit Error:2 may be due to use of old clidriver which has a gskit bug. You have not shared db2level output of clidriver, but it should be some older version and not the latest once. Replace your existing clidriver pointed out by IBM_DB_HOME with this clidriver. It may fix this issue. Thanks.

Oh sorry, I just downloaded it, it's v11.5.9_ntx64_odbc_cli.zip. I tried with the one you included and I got the same error.

If it matters, my connection string:
DATABASE={Database name};HOSTNAME={host name};PORT={JDBC Port};PROTOCOL=TCPIP;UID={user ID};PWD={user password};SECURITY=SSL;SSLServerCertificate={absolute file path}{file name}.jks

@chrisstephens1 The GSKit Error: 2 means 2 - GSK_API_NOT_AVAILABLE. This error comes on windows when old version of gskit library path is set in PATH system level environment variable and it get loaded by the driver. If you have C:\Program Files\ibm\gsk8 directory in your system, remove it from PATH and LIB system level environment variables or at least from the command prompt which run test program.
If you do not have C:\Program Files\ibm\gsk8, I would suggest to still check PATH and LIB env var that it has path of another driver in your system or not.
Finally, a java certificate file may be the issue, so try to get .arm or .cert file and then use for SSLServerCertificate.

Please share output of below commands from windows command prompt if possible:

set PATH=%IBM_DB_HOME%/bin;%PATH%
set LIB=%IBM_DB_HOME%/lib;%IBM_DB_HOME%/lib/icc;%LIB%
echo %PATH%
echo %LIB%
db2cli writecfg add -dsn ssldsn -database <dbname> -host <hostname> -port <sslport> -parameter "userid=<dbuser>;password=<dbpass>;SecurityTransportMode=SSL;SSLServerCertificate=<full_path_of_cert_file>;"
db2cli validate -dsn ssldsn -connect

Complete output of above validate command will help to know your system configuration.
Thanks.