Differences between revisions 2 and 3
Revision 2 as of 2008-07-08 11:27:44
Size: 1356
Editor: localhost
Comment: converted to 1.6 markup
Revision 3 as of 2009-10-28 19:42:10
Size: 1361
Editor: ThomasHeller
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
#test
Line 31: Line 32:

Things that can go wrong with py2exe and services

within demos/advanced there is an example to create windows services with py2exe. It works quite out of the box.

Difficulties arise later on - as soon as you wanna do something REAL with that service.

Error Message

Python could not import the service's module 
  File "C:\ham\jds\syncservice.py", line 21, in ?
    import transinhalte
  File "C:\ham\jds\transinhalte.py", line 17, in ?
    import unite
  File "C:\ham\jds\unite.py", line 9, in ?
    import version 
exceptions.ImportError: dynamic module does not define init function (initversion)

yours might be different ... what went wrong????

Everything worked fine as long as I was running that service within debug mode. Then, starting it up as "real service", this error appeared.

a Mail of Gerald Haering showed me the light: when a service is started, all paths are TOTALLY DIFFERENT ANIMALS then in any other running state of python... so, the service tried to load version.dll, which is something that comes within windows/system32, and of course has NO Python init-code.

Solution

Make sure that NONE of your Python module names conflicts with ANY of the windows system dll names

py2exeAndWindowsServices (last edited 2015-12-07 09:41:17 by TijnGommans)