Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python, Windows service Import error

I am trying to run a python application as a Windows Service. The code I have installs and starts but I am having issues importing modules and classes which are part of the application.

Note:: Python libraries are being included fine.

I have checked the python path and all the correct values are in there, (including the application directory) which is leading me to believe that the windows service could be running in a different location.

Does a python application running as a windows service get run from a different location on windows?

like image 256
Matt Seymour Avatar asked Dec 19 '12 10:12

Matt Seymour


1 Answers

python service creation using win32service created the pythonservice.exe in C:\Python27\Lib\site-packages\win32 by default.

you can perform os.chdir(yourdir) in your code just before service creation,

the best thing would be use absolute paths and setting proper sys.path within your script for accessing files

like image 134
avasal Avatar answered Oct 14 '22 08:10

avasal