ibmdb / python-ibmdb

Automatically exported from code.google.com/p/ibm-db
Apache License 2.0
304 stars 193 forks source link

Need help with python library ibm_db #952

Open ldmarquez opened 1 week ago

ldmarquez commented 1 week ago

I have developed a program in Python 3.12 language, in a Windows 11 environment, that interacts with a DB2 database on AS400. Reading the manuals they tell me to use the "ibm_db" library which I install using pip.

C:\Users\User>pip install ibm_db Collecting ibm_db Downloading ibm_db-3.2.3-cp312-cp312-win_amd64.whl.metadata (1.4 kB) Downloading ibm_db-3.2.3-cp312-cp312-win_amd64.whl (27.8 MB) ━━━━━━━━━━━━- 7.8/27.8 MB 2.3 MB/s eta 0 :00:00 Installing collected packages: ibm_db Successfully installed ibm_db-3.2.3

In the program I have the instruction:

"import ibm_db"

When running the program it displays this error:

"Traceback (most recent call last): File "D:\A6_ABG_SI\PlanificacionTareasMigracion\CONSULTAS\AsCuentaFilas.py", line 13, in import ibm_db ImportError: DLL load failed while importing ibm_db: Cannot find the specified module."

To check that the module is installed, I execute the pip show instruction:

C:\Users\User>pip show ibm_db Name: ibm_db Version: 3.2.3 Summary: Python DBI driver for DB2 (LUW, zOS, i5) and IDS Home-page: http://pypi.python.org/pypi/ibm_db/ Author: IBM Application Development Team Author-email: praveen.narayanappa1@ibm.com License: Apache License 2.0 Location: C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages Requires: Required-by:

This is where I get the email address and that's why I'm asking.

Please could you guide me to solve this error?

Earammak commented 1 week ago

@ldmarquez , Please refer to https://github.com/ibmdb/python-ibmdb?tab=readme-ov-file#installation You need to set dll path of dependent library of clidriver before importing the module as: import os os.add_dll_directory('path to clidriver installation until bin') import ibm_db

bimalkjha commented 1 week ago

@ldmarquez Use below commands:

import os
os.add_dll_directory(r'C:\\Users\\User\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\clidriver\\bin')
import ibm_db

Thanks.