WindowsError: [Error 126] when loading a DLL with ctypes

前端 未结 2 1686
予麋鹿
予麋鹿 2020-12-03 08:20

This works fine on Windows 7 with Python 2.7:

lib = ctypes.cdll.LoadLibrary(\'prov_means\')
provmeans = lib.provmeans  

The library prov_me

相关标签:
2条回答
  • 2020-12-03 08:38

    Which compiler did you use to build the library? Maybe some required libraries are missing? You can check what dependencies the library has with Dependency Walker (http://www.dependencywalker.com/)?

    0 讨论(0)
  • 2020-12-03 08:45

    Error 126 is what you get when a dependent DLL can not be found. There are two obvious causes for this:

    1. Your DLL is not being located.
    2. Your DLL depends on other DLLs that cannot be found.

    I doubt that option 1 is the problem but in any case I think I would probably be using a full path to that DLL to be sure.

    So that leaves option 2 and the most common cause for that is that your target machine does not have the C++ runtime installed. Either install the C++ runtime on your target machine, or use static linking, /MT, when building your DLL so that you do not need to redistribute the runtime.

    Probably, on the machine that you developed the DLL, you have installed a C++ compiler and that installed the runtime for you. On your target machine, where the code fails, you have not installed the compiler and so the runtime is not present.

    0 讨论(0)
提交回复
热议问题