[python-win32] Failure to import zlib in Windows services

Tony Meyer t-meyer at ihug.co.nz
Thu Nov 11 02:15:23 CET 2004


[Tony]
>> I can't import zlib from a script running as a Windows 
>> service.  If I do, this entry appears in the event log:

[Mark]
> I suspect you have a zlib.dll in your system32 directory - 
> this is often the CWD when run as a service.

I knew posting a message asking for help would be quicker than trying to
figure it out myself (although I had begun to suspect something like that)
:)  Thanks!

> I really should fix the service implementation to handle this 
> common error.

Is it that common?  I googled about trying to find a solution, and couldn't
find much.  But yes, fixing would be good :)  Want me to open a bug tracker?

> A quick hack would be something like:
> 
> if sys.path[0]=="":
> 	sys.path[0] = os.path.dirname(__file__)
> 
> (or something like that :)

My problem was actually that the system32 directory was before the
PythonXX\DLLs directory (i.e. the CWD didn't come into it).  So I ran
through sys.path and bumped that to the end if it was there.  Hackish, but
should do for now, anyway.

Thanks for the (quick!) help :)

Cheers,
Tony



More information about the Python-win32 mailing list