开发者

Windows services with Python and py2exe

I need some help with converting a python windows service using py2exe.

Let me explain the problem. I have a python service, which works, no problems here. I used py2exe to turn it into an executable file. I tested it by replacing the python version of the service with this one and it works with no problems too.

But when I move the exe version of the service to another computer, it will register with the service manager but won't start with the error: "The system cannot find the file specified". The missing file is one of the modules I've written.

I played with this a bit and went back to the machine where I used py2exe and where the exe version of the service works. I removed everything python related, everything py2exe created but the "dist" folder, everything I could think of that was related with the python version of the service. The exe version still worked (altho I removed, amongst others, the very files that were supposedly missing on the other machine).

Tried a bunch of different things but cant get the exe version to work. If any of you guys have any ideas, I'd really appreciate it.

P.S: I d开发者_StackOverflow社区o have the c++ runtime installed on the target machine. You can't register the service without it and as I said, I can register it, it just won't run.


Even if you converted the .py script to an exe, the service still uses the python interpreter to run the service code itself. if you open "Services" and look at the service properties you should see something like - Path to executable: "C:\Python27\lib\site-packages\win32\PythonService.exe"

i'm guessing the other computer doesnt have python installed on it. if you want to be able to run that service on a machine without installing python you need to do something like This ,or you can also do it using cx_freeze


http://www.py2exe.org/index.cgi/py2exeAndWindowsServices

There are some notes in there about modules conflicting with windows system dlls. He had a problem because he had a module called version and import version caused the app to error out.

You can try importing win32traceutil as the first thing in your service. This should allow you to run the win32traceutil console app to display any stdout/stderr output from the service.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜