Skip to content

Fix DLL load failure on Windows , update workflow and simplify sdist packaging#1053

Open
Earammak wants to merge 6 commits intoibmdb:masterfrom
Earammak:fix_dll_error_issue
Open

Fix DLL load failure on Windows , update workflow and simplify sdist packaging#1053
Earammak wants to merge 6 commits intoibmdb:masterfrom
Earammak:fix_dll_error_issue

Conversation

@Earammak
Copy link
Copy Markdown
Collaborator

@Earammak Earammak commented Apr 7, 2026

This PR addresses DLL resolution issues for ibm_db on Windows with Python ≥3.8. Since Python 3.8, the system PATH is no longer used for DLL resolution, which causes ImportError: DLL load failed when importing ibm_db because the clidriver DLLs cannot be found.

Problem
Python 3.8 changed DLL search behavior on Windows (Python issue #36085).

As a result, ibm_db fails to import if clidriver DLLs are not explicitly registered.

Introduce a startup hook (_ibm_db_register_dll.py) that uses os.add_dll_directory() to register the clidriver bin path automatically.
Trigger the hook via a .pth file (ibm_db_dll.pth) placed in site‑packages, ensuring DLL registration happens at Python startup.
This makes import ibm_db work out of the box on Windows without manual configuration.

updated workflow file and README.md file.

if ibm_home:
candidates.append(os.path.join(ibm_home.strip('"'), "bin"))

# 2. User site-packages/clidriver (pip install --user)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bchoudhary6415 Other code should be inside else block if ibm_home is not set.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. will correct it.

Copy link
Copy Markdown
Member

@bimalkjha bimalkjha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct clidriver path logic in _ibm_db_register_dll.py file. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ImportError: DLL load failed while importing ibm_db:

3 participants