這工作正常的Windows 7使用Python 2.7時:WindowsError:[錯誤126]加載與ctypes的一個DLL
lib = ctypes.cdll.LoadLibrary('prov_means')
provmeans = lib.provmeans
圖書館prov_means.DLL是我的工作目錄。它導出一個簡單的,獨立的C函數provmeans()而不依賴任何依賴項。
當我嘗試在Windows XP和Python 2.7同樣的事情,我得到
Traceback (most recent call last):
File "D:\python\Auxil\src\auxil.py", line 130, in <module>
lib = ctypes.cdll.LoadLibrary('prov_means')
File "C:\Python27\lib\ctypes\__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "C:\Python27\lib\ctypes\__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found
我試圖複製DLL到Windows \ System32下,也與進入全路徑名
"d:\\python\\auxil\\src\\prov_means"
並沒有「.DLL」擴展名。什麼都沒有
謝謝大衛。聽起來非常有道理,因爲我在Windows 7機器上編譯了Visual Studio 2010 Express,而該機器不在目標機器上。我按照建議在目標機器上安裝了C++運行時並重新啓動。同樣的錯誤不幸。 – MortCanty
您可以在配置文件模式下使用Dependency Walker來檢查它。但我會考慮用'/ MT'重建DLL,只是爲了仔細檢查它是不是導致問題的依賴。 –
對,剛剛用/ MT重建,它現在在目標上運行。非常感謝! – MortCanty