-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImportError: DLL load failed while importing ibm_db: #887
Comments
@ZephyrusMB, Can you please run as below, before import ibm_db. |
Also upgraded from ibm-db version 3.1.4 to 3.2.0 and ran into the error "ImportError: DLL load failed while importing ibm_db". |
@ZephyrusMB This we need to add manually for windows only. And the same is documented in README. |
I studied the README before posting this comment, so it was clear to me what needed to be done. The issue I want to address is that this package is not downwards compatible and platform agnostic anymore and we need to change several scripts. Using ibm-db==3.1.4 we can run the same scripts on Windows, Linux and in Containers. If I want to use ibm-db==3.2.0 I have to alter these scripts to check if os.name == 'nt' (or os.name != 'posix') and then execute os.add_dll_directory(os.getenv('IBM_DB_HOME') + '/bin'). I'm using this driver mainly in combination with RobotFramework (this is a testautomation framework) third party libraries (e.g. robotframework-databaselibrary). I don't want to change these third party libraries, so need to use IF and Evaluate construction to make it platform independent in my testscripts again:
The question is, can't you add this construction:
or other construction to the ibm-db module to make it platform agnostic again and downwards compatible with ibm-db==3.1.4? If there is good reason to not do this, please shed some light on this as to why. Is it conflicting somewhere else? If it cannot be changed, then we will stick to ibm-db==3.1.4 for now an change our scripts later on to work with ibm-db=3.2.0 or later version. |
@Earammak I'm getting this error: |
Yes please as described by @dverweij-dev the expected behavior is to be platform agnostic as in version 3.1.4. Kind regards |
@frbelotto You need to run below command as documented here as Note:
Also, this solution is already given in this comment: #887 (comment) |
@Rishi-spec-art they mean something like:
... whatever the path is to where pip put your clidriver/bin. IBM team, I'd suggest clarifying that wording. "until bin" sounds to me like you don't want it to stop at "clidrivder/" |
Just to understand. Such installation (ODBC and CLI driver) wasn't needed before? I have been using IBM_DB for a while and started getting this error recently. |
@readytheory Yes, do not stop at clidriver but clidriver/bin as in |
@frbelotto You are right. Actually from ibm_db version 3.2.0, we have discontinued shipping ibm_db.dll file and switched on wheel support for Linux, Mac and Windows to avoid compilation related issues. So, change in behavior. Thanks. |
I got this error despite following the guide
Bellow is the error ImportError: DLL load failed while importing ibm_db: The specified module could not be found. |
@LinusConradM Seems you have not went through the comments in this issue. Please check it: #887 (comment) Thanks. |
add_dll_directory to every script that needs db2 access? What a terrible user experience, I can't believe this is the best answer. Please re-evaluate the strategy. |
Does anyone can confirm what is the lastest version of the library that does not request adding the dll manually? I want to set it up on my requests.txt. |
@frbelotto python-ibm_db v3.1.4 is the latest version of the library that does not request adding the dll manually. Also from python version Before Python 3.8, the DLL search path was influenced by the PATH environment variable. However, this could lead to issues, especially when Python was embedded in larger applications. The os.add_dll_directory() function was introduced to provide a more controlled and isolated way of managing the DLL search path. Here's a basic example of how to use os.add_dll_directory(): import os Add a directory to the DLL search path Now, when loading a DLL or using ctypes, the specified directory is considered in the search path It's important to note that this function is available only in Python 3.8 and later versions. If you're working with an earlier version of Python, you might need to consider alternative approaches or upgrade to a newer Python version. Thanks. |
Regardless of whether you end up adding the ddl back or not, could you consider issuing deprecation warnings for breaking changes in the future? Edit: Especially considering that installs for <3.2 are now also retroactively fucked because it relied on pulling the DDL from master, which is no longer there, so rolling back is not even an option. |
I'm running into this issue on redhat, it's failing to create databases but I can query existing ones:
Am I missing something here? |
I have found a way to copy the |
This works fine, can connect to db2 after running os.add_dll_directory. |
@ksaket1998 In your python script, you need to code to find the correct
Then check for clidriver under site_packages or directly check for clidriver instead of ibm_db* file. Then construct full path till clidriver\bin and add it to os.add_dll_directory(). Thanks. |
hey buddy, how are you? I have found a solution that at least it has helped me and other users, was to uninstall the library after the driver and do the step by step again. 1.- Install the IBM Driver from os import add_dll_directory
from os import environ
if "IBM_DB_HOME" not in environ["PATH"]:
add_dll_directory(r"path ibm drivers")
from ibm_db import connect
p8cmprod_connection = connect("dsn", "user", "password") I have also seen the solution of mapping to the clidriver that comes with the library but at least it didn't work for me, so any solution that works for you would be good to know. |
@frbelotto To install or update python ibm_db driver, no need to install DB2 Client. It automatically downloads and install clidriver internally. But, if you have requirement to use specific version of Db2 Client or driver and want to avoid automatic download of clidriver during installation of ibm_db, then you need to follow the requirement of installation of Db2 Client.. and yes, most of the website wants registration to know their users. |
Hello! I've tried to install ibm db today, but as expected it was complaining about a missing DLL. I don't need to use any specific version. I am trying to use a newer version so I could start using Python 3.12 |
@frbelotto This missing DLL error on windows is a known issue and we have already documented the solution and updated on this comment too. Thing is the path of clidriver/bin directory that you need to pass to |
@frbelotto Below is the complete steps with example that show there is no db2 client installed in my system and how ibm_db works on windows. I have python3.10 installed in my system, so same is used in this example. Same works for python 3.12 too.
Thanks. |
@Gamhigh import os Please don't share your userID and Password here. Thank you |
@bchoudhary6415 thank you very much, I was able to log in. I know it's fake password |
"ImportError: DLL load failed while importing ibm_db" raised while executing script. Working with ibm_db version 3.1.4.
Dlls are not present with 3.2.0 version.
Operating System Name: Microsoft Windows 11 10.0.22621
Python Version: 3.11.4 and 3.11.5
ibm_db version: 3.2.0
Test script to reproduce the problem
Failed at line 1
import ibm_db
Steps to Reproduce:
pip install --upgrade ibm_db
The text was updated successfully, but these errors were encountered: