2010-06-23 294 views
8
ctypes.WinDLL("C:\Program Files\AHSDK\bin\ahscript.dll") 

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "C:\Python26\lib\ctypes\__init__.py", line 353, in __init__ 
    self._handle = _dlopen(self._name, mode) 
WindowsError: [Error 126] The specified module could not be found 

我該如何解決?我在C:\Python26\lib\ctypes\__init__.py找到了_dlopen,但我真的不知道如何解決它。Python ctypes.WinDLL錯誤,_dlopen(self._name,mode)找不到

回答

7

反斜槓都是字符串內轉義字符,如在下面的例子表明:

>>> print "C:\Program Files\AHSDK\bin\ahscript.dll" 
C:\Program Files\AHSDinhscript.dll 

可以由字符串,這防止了反斜槓從作爲轉義字符工作之前放置的R解決問題:

ctypes.WinDLL(r"C:\Program Files\AHSDK\bin\ahscript.dll") 

或者,您可以逃避反斜槓:

ctypes.WinDLL("C:\\Program Files\\AHSDK\\bin\\ahscript.dll") 
+0

這是工作,thx爲您的幫助! – wizztjh 2010-06-24 07:08:31