[python-win32] Can't import wmi in scripts run by nrpe_nt

Tim Golden tim.golden at viacom-outdoor.co.uk
Wed Oct 27 09:25:15 CEST 2004


| BTW, I'd like to congratulate you on wmi. If it weren't so 
| useful to me I wouldn't be trying to solve this problem.

Thanks for the bouquet. In fact, the people who really deserve
congratulations are the MS team who put the WMI stuff together,
and Mark H and the other contributors to pywin32. All I've
done is put some lightweight plumbing in place to make the
whole experience a little easier to cope with.

| I'm sorry, I could have phrased this better.

That's all right; your explanation below (snipped) makes
it perfectly clear. I suspect the problem is that the nrpe_nt
process runs as a service. There is (probably) a .dll called
wmi in your windows system directory. When the service runs,
it probably runs as the system user in the system directory.
When it imports wmi, it actually tries to import the wmi.dll
(which is nothing to do with Python, but rather to do with
wmi itself). It either fails nicely or bombs completely,
depending slightly on what version of Python you're running.

Two possible solutions, both quite simple:

a) Run the service outside the c:\winnt\system32 (or whatever)
   directory. Or at least do an os.chdir before importing wmi.
b) Rename wmi.py on that machine to pywmi.py (or whatever other
   name takes your fancy) and try again.

Let me know if that helps

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


More information about the Python-win32 mailing list