2

When Python fails to load a dependency of a C extension module, it shows a cryptic error message that doesn't really help you solve the issue.

>>> import mymodule
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing mymodule: The specified module could not be found.

mymodule.pyd is there, but it has a dependency on something else that is not visible to the Python executable. How can I figure out exactly what dependency is failing?

Note that I'm not looking for help on specific packages, but for a generic way to solve this issue.


Edit: Turns out python is just relaying whatever error message it gets from Windows when trying to load the dll, so I guess this is more a Windows cryptic message than Python's.

CPython dll import source code

Diego Sánchez
  • 539
  • 2
  • 12
  • 1
    Those Python modules are technically just DLLs, so you can use the same tools as for finding DLL dependencies. – Ulrich Eckhardt Jul 30 '22 at 15:27
  • 2
    Does this answer your question? [How to check for DLL dependency?](https://stackoverflow.com/questions/7378959/how-to-check-for-dll-dependency) – Ulrich Eckhardt Jul 30 '22 at 15:28
  • @UlrichEckhardt Yes, thanks. It seems that the problem is the same. There's the added difficulty of the restricted search path in CPython (which may confuse you if other tools happily load your libraries) but, in essence, this is a dll-dependency problem in Windows. I would still leave my question here as, like me, others may not make that association at first. – Diego Sánchez Jul 30 '22 at 16:24

0 Answers0