我想從Python加載.dll。我在Visual Studio 2017 Preview中使用Python 3.0.17114.1。我收到一個錯誤,說「NameError:名稱LoadLibrary未定義」。Python LoadLibrary找不到
下面是一個代碼剪斷(注意theDll出來完美):
import ctypes
from ctypes.util import find_library
from ctypes import LibraryLoader
from ctypes.util import find_library
theDll = find_library('DsiLibrary_dll')
dsi_lib = LoadLibrary(theDll)
所以我在調用LoadLibrary念起來有幾個不同的方式來做到這一點。我嘗試了所有我能找到的:
cdll.LoadLibrary(theDll)
CDLL.LoadLibrary(theDll)
ctypes.CDLL.LoadLibrary(theDll)
ctypes.LoadLibrary(theDll)
我對Python很新,所以我可能犯了一些愚蠢的錯誤。有人可以提出建議嗎?
我用了你的Windows方法,但給出了同樣的沒有定義的錯誤。 – Eddy
對我來說沒有錯誤,你做了什麼? – abccd
我從你的帖子中做了剪貼。從ctypes的進口ctypes的 cdll 導入從ctypes.util進口find_library theDll = find_library( 'DsiLibrary_dll') dsi_lib = cdll.LoadLibrary(theDll) – Eddy