473,670 Members | 2,609 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "<interacti ve input>", line 1, in ?
File "C:\Python24\Li b\site-packages\ctypes \__init__.py", line 387, in
__getattr__
dll = self._dlltype(n ame)
File "C:\Python24\Li b\site-packages\ctypes \__init__.py", line 312, in
__init__
self._handle = _dlopen(self._n ame, 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\\sys tem32\\arapi51. dll'

At that point I try to use the LoadLibrary function, but it still can't
find it:
>>windll.LoadLi brary('C:\WINNT \system32\arapi 51.dll')
Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
File "C:\Python24\Li b\site-packages\ctypes \__init__.py", line 395, in
LoadLibrary
return self._dlltype(n ame)
File "C:\Python24\Li b\site-packages\ctypes \__init__.py", line 312, in
__init__
self._handle = _dlopen(self._n ame, 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

Oct 24 '06 #1
6 30912
Mudcat a écrit :
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:
(snip)
WindowsError: [Errno 126] The specified module could not be found

So then I use the find_library function, and it finds it:
(snip)
At that point I try to use the LoadLibrary function, but it still can't
find it:
(snip)
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.
Looks like it could have to do with another dll arapi51.dll depends upon
that would be missing, cf:
http://aspn.activestate.com/ASPN/Mai...-users/2593616

HTH
Oct 24 '06 #2
"Mudcat" <mn******@gmail .comwrites:

Is the DLL loadable from a standalone C program?
All that is needed is a call to LoadLibrary() and check the return.

If the full path is not specified, the dll is searched in the predefined order
- I believe it is
executable directory - in this case, directory of python.exe
current directory - set the current drive and path to whereever you want
before trying to load the dll
windows system directory
windows directory
Directories specified in PATH evnvironment variable

-Chetan
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 "<interacti ve input>", line 1, in ?
File "C:\Python24\Li b\site-packages\ctypes \__init__.py", line 387, in
__getattr__
dll = self._dlltype(n ame)
File "C:\Python24\Li b\site-packages\ctypes \__init__.py", line 312, in
__init__
self._handle = _dlopen(self._n ame, 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\\sys tem32\\arapi51. dll'

At that point I try to use the LoadLibrary function, but it still can't
find it:
>>>windll.LoadL ibrary('C:\WINN T\system32\arap i51.dll')
Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
File "C:\Python24\Li b\site-packages\ctypes \__init__.py", line 395, in
LoadLibrary
return self._dlltype(n ame)
File "C:\Python24\Li b\site-packages\ctypes \__init__.py", line 312, in
__init__
self._handle = _dlopen(self._n ame, 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
Oct 25 '06 #3

Mudcat wrote:

So then I use the find_library function, and it finds it:
>find_library(' arapi51.dll')
'C:\\WINNT\\sys tem32\\arapi51. dll'
Notice it's escaped the '\' character.
At that point I try to use the LoadLibrary function, but it still can't
find it:
>windll.LoadLib rary('C:\WINNT\ system32\arapi5 1.dll')
Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
File "C:\Python24\Li b\site-packages\ctypes \__init__.py", line 395, in
LoadLibrary
return self._dlltype(n ame)
File "C:\Python24\Li b\site-packages\ctypes \__init__.py", line 312, in
__init__
self._handle = _dlopen(self._n ame, mode)
WindowsError: [Errno 126] The specified module could not be found

What am I doing wrong? [snip]
You need to use either
windll.LoadLibr ary(r'c:\winnt\ system32\arapi5 1.dll') or escape the \'s
as the find_library function did. You're getting caught out by \a which
is the alert/bell character. \w and \s aren't valid escape sequences so
you get away with them. I'm guessing it's worked before because you've
been lucky.

Works fine!:
>>'C:\winnt\sys tem32\smtpctrs. dll'
'C:\\winnt\\sys tem32\\smtpctrs .dll'

Uh oh, escaped:
>>'C:\winnt\sys tem32\arapi51.d ll'
'C:\\winnt\\sys tem32\x07rapi51 .dll'

Jon.

Oct 25 '06 #4
"Jon Clements" <jo****@googlem ail.comwrites:
Mudcat wrote:

So then I use the find_library function, and it finds it:
>>find_library( 'arapi51.dll')
'C:\\WINNT\\sys tem32\\arapi51. dll'

Notice it's escaped the '\' character.
At that point I try to use the LoadLibrary function, but it still can't
find it:
>>windll.LoadLi brary('C:\WINNT \system32\arapi 51.dll')
Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
File "C:\Python24\Li b\site-packages\ctypes \__init__.py", line 395, in
LoadLibrary
return self._dlltype(n ame)
File "C:\Python24\Li b\site-packages\ctypes \__init__.py", line 312, in
__init__
self._handle = _dlopen(self._n ame, mode)
WindowsError: [Errno 126] The specified module could not be found

What am I doing wrong? [snip]

You need to use either
windll.LoadLibr ary(r'c:\winnt\ system32\arapi5 1.dll') or escape the \'s
as the find_library function did. You're getting caught out by \a which
is the alert/bell character. \w and \s aren't valid escape sequences so
you get away with them. I'm guessing it's worked before because you've
been lucky.

Works fine!:
>'C:\winnt\syst em32\smtpctrs.d ll'
'C:\\winnt\\sys tem32\\smtpctrs .dll'

Uh oh, escaped:
>'C:\winnt\syst em32\arapi51.dl l'
'C:\\winnt\\sys tem32\x07rapi51 .dll'
I wondered about it, but that would not explain why it fails in the first case
- perhaps the OP now knows what happened. Interestingly I get a different
error with the distribution binary for 2.5 - I get "Error 22" instead of "Errno
126", but the message text was same, so I assumed this was from a different
version and something had changed about how the errno is reported.

However, I checked the windows error codes and 126 seems to be the correct
error. The error code talks about bad command and the corresponding message
text reads "The device does not recognize the command."

-Chetan
>
Jon.
Oct 25 '06 #5
That was it. Once I added the other DLLs then it was able to find and
make the call.

Thanks for all the help,
Marc
Bruno Desthuilliers wrote:
Mudcat a écrit :
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:
(snip)
WindowsError: [Errno 126] The specified module could not be found

So then I use the find_library function, and it finds it:
(snip)
At that point I try to use the LoadLibrary function, but it still can't
find it:
(snip)
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.

Looks like it could have to do with another dll arapi51.dll depends upon
that would be missing, cf:
http://aspn.activestate.com/ASPN/Mai...-users/2593616

HTH
Oct 28 '06 #6
Mudcat a écrit :
That was it. Once I added the other DLLs then it was able to find and
make the call.

Thanks for all the help,
I just googled for "WindowsErr or: [Errno 126]" and followed the links,
you know...
Oct 31 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
23078
by: Familie Spies | last post by:
Hi all, When running a program I made in VB under Windows XP i'm getting the following error: ! Compile error. Can't find project or library. (see also http://home.kabelfoon.nl/~hspies/2.jpg ) See the code where it stucks: http://home.kabelfoon.nl/~hspies/1.jpg Ubder Windows 98 this error does not occur. Who knows what I do wrong, I've tried a lot but the error keeps coming in Win XP. Thanks.
2
2291
by: Kathy | last post by:
Hi All, I have several users who are getting a compile error "Can't find project or library when the code hits Dim cat as ADOX.Catalog In the references dialog box it show the msadox.dll as missing BUT it's in it's folder right where it belongs. I'v tried decompiling the database using the switch to no avail. The database runs fine on my machine. No one had any problems with it yesterday and nothing has changed.
0
1334
by: John Doe | last post by:
Windows XP Visual Studio 2003 NET Visual C++ When I tried to run without debugging, I get a message that says it can't find a path. The path did exist on my computer. I cannot find the path text (my search criteria is only one word from the path) in the solution or anywhere on my computer. Here is the error when I try to run without debugging, after
2
2193
by: Ben | last post by:
Hi, In the code-behind, i can refer to the dropdownlist defined in the aspx file with this (e.g.) dropdownlist1.sekectedvalue = ... but why can i not refer to the label defined in the TemplateField in the same aspx file like below? This gives the error: "can't find control 'mylabel' ": mylabel.text="ok"
4
7577
by: nekker64 | last post by:
Hi, I have this complete Audit database at work that I inherited from someone who left late last year, it has been working fine up until this week. There are report form section that I can select reports by specific topics, but when I select and press that report button, instead of the report opening up, I get the this error message pop up "Compile error: Can't find project or library" and then the Visual BAsic editor opens with code info...
1
7039
by: rave3085 | last post by:
Helo friends, I Had a VB Project in my system which was not done by me! But when i tried to Run that it gave me a message! Compile Error: Can't Find Project Or Library! Immediately after that, the References Box opens automatically showing MISSING:Microsoft DTSPackage Objects Library alomg with all the other references selected!!!
1
2603
by: Bob | last post by:
Hi all, I've created a database at work and have copied it to home but have had some problems when I try to open the main form. The error when I run it is: Compile error: Can't find project or library This error comes up then it highlights the 'date' function in the following line of code:
2
1825
by: wouter | last post by:
Hello, Being a chemical engineering i'm only little acquainted with programming. However I made a made a excel program with macro's using VBA. This program is used a lot in our company. However when going from windows 2000 to windows 2003, it does not work anymore!! When running, it gives the error: Compile error; can't find project or library. Does someone know how to tackle this problem?
8
2108
by: creative1 | last post by:
Hello Experts I got a problem that I can't solve onmy own. I hope to get a solution from you guys.I was working on project on my PC and some times I use to work on my laptop(when I was away from my PC). I t work good at both spots. For some days when I execute my project I get this error: Compile error: Can't find project library if I say ok, it takes me to available reference window. IT points to Missing Jet and Replication object 2.6...
1
3763
by: squrel | last post by:
Hello all.. i need a very urgent help here... i have done a project in VB6 and SQLServer 2000 but few days back my pc had to get formatted and i took the back up of my project. i have installed VB again and my project also bt now when i want to run the project i m getting this error : Compile error : can't find project or library i have checked the components and refrences also and everything is thr bt still not opening... plz tel me wht...
0
8386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8592
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8661
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7421
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6216
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4213
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4393
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2802
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1795
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.