Skip to content

'ImportError: DLL load failed' when importing 2 modules with a similar dll file name #143899

@mrrezaie

Description

@mrrezaie

Bug report

Bug description:

Hi,

I need to use two modules, let's say A and B. Both having a specific dll file in their path (Lib/site-packages/A/xxx.dll and Lib/site-packages/B/xxx.dll). B is the original package in C++, and is a compiled and distributed by A as well.

Both work well independently. However, I need to import both and work with them simultaneously. The order of import matters; the later one ends up with:
ImportError: DLL load failed while importing _ezc3d: The specified procedure could not be found.

I tried removing any reference from below, followed by importing the later one; but failed again.

globals()
locals()
os.environ['PATH']
sys.modules
sys.path

I also tried adding the path for the later one, as follows, failed again.

ctypes.util.find_library
sys.path.insert
ctypes.windll.LoadLibrary
os.environ['PATH']
os.add_dll_directory

I was wondering if there is any solution. Thank you in advance.
(Just in case, A is opensim, and B is ezc3d)

CPython versions tested on:

3.14

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions