简体   繁体   English

Windows服务在Anaconda环境中运行?

[英]Windows service running in a Anaconda environment?

I need to run a Flask application as a Windows service. 我需要将Flask应用程序作为Windows服务运行。 I managed to convert it to a Windows service using win32serviceutil. 我设法使用win32serviceutil将其转换为Windows服务。 The problem I have is that it only works when I manually run PythonService.exe (with the -debug flag) from the "activated" environment (of course). 我的问题是,仅当我从“激活的”环境(当然)中手动运行PythonService.exe(带有-debug标志)时,它才起作用。

Is there a way to activate the environment before attempting to run the service? 是否有办法在尝试运行服务之前激活环境?

I see some people used the Task Scheduler as a workaround but I'd prefer if Windows service manager could be used instead. 我看到有人使用Task Scheduler作为一种解决方法,但我更愿意使用Windows Service Manager。

I figured it out. 我想到了。 The trick is to use pyinstaller to generate an EXE. 诀窍是使用pyinstaller生成EXE。 This way all libraries will be included, and there will be no need to mess with the system environment variables. 这样,将包含所有库,并且无需弄乱系统环境变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM