Ctypes Error: Why can't it find the DLL.



Hi,

I can't figure out why ctypes won't load the DLL I need to use. I've
tried everything I can find (and the ctypes website is down at the
moment). Here's what I've seen so far.

I've added the file arapi51.dll to the system32 directory. However
when I tried to access it I see this:

print windll.arapi51 # doctest: +WINDOWS
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Python24\Lib\site-packages\ctypes\__init__.py", line 387, in
__getattr__
dll = self._dlltype(name)
File "C:\Python24\Lib\site-packages\ctypes\__init__.py", line 312, in
__init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Errno 126] The specified module could not be found

So then I use the find_library function, and it finds it:

find_library('arapi51.dll')
'C:\\WINNT\\system32\\arapi51.dll'

At that point I try to use the LoadLibrary function, but it still can't
find it:

windll.LoadLibrary('C:\WINNT\system32\arapi51.dll')
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Python24\Lib\site-packages\ctypes\__init__.py", line 395, in
LoadLibrary
return self._dlltype(name)
File "C:\Python24\Lib\site-packages\ctypes\__init__.py", line 312, in
__init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Errno 126] The specified module could not be found

What am I doing wrong? I've used ctypes before and not had this
problem. Before, I've just added the file to the system32 directory and
not had this problem.

On another note, if I wanted to include these DLL's to be a part of an
installable package, how would I configure ctypes to use DLL's from a
local directory?

Thanks,
Marc

.



Relevant Pages

  • Re: [Q] ctypes callbacks with Delphi
    ... >> I'm aving some trouble getting callbacks from a Delphi DLL back to ... >> python working through ctypes. ... When I search for 'Delphi', ... If anyone is using ctypes with called-back functions written in python ...
    (comp.lang.python)
  • Re: re - Question about pyFMOD importing
    ... > Were you able to hack this one? ... I guess that the library that ctypes looks for is the ... DLL required for FMOD. ... The library search path should include the current path ...
    (comp.lang.python)
  • Re: Access to CAN-Bus
    ... Googling around I couldn't find a Python package, ... Under Windows, I guess, I could use some COM or ctypes functionality to ... access the hardware vendor's hardware. ... Maybe the DLL is downloadable from the company's website. ...
    (comp.lang.python)
  • Re: python - dll access (ctypes or swig)
    ... >Daniel Watrous wrote: ... >> have four exported functions and a host of COM Properties and COM ... >> I am able to load the DLL using ctypes and it can access the exported ... You don't have a traditional .DLL that you would ...
    (comp.lang.python)
  • Re: Ctypes Error: Why cant it find the DLL.
    ... I can't figure out why ctypes won't load the DLL I need to use. ... I've added the file arapi51.dll to the system32 directory. ...
    (comp.lang.python)