Discussion:
[python-win32] PythonService.exe Network Service
Nyland, Christopher F CTR USARMY AMSAA (US)
2015-08-26 17:28:47 UTC
Permalink
Hello,

So I am trying to implement a small internal web server using Flask and Tornado. I would like it to run as a service. I am running into a problem though some of my underlying code needs to use UNC paths to grab files off other computers on the network. However at lease on our machine it seems the only way to do this is to run as a network service or at least that is what I want to try. So I made a stripped down version of the service and it will run fine a a local system service. If I change it to run as a Network Service it keeps failing. I keep getting error messages from the windows log like below

Python could not import the services's module
ImportError: No module named service
%2: %3

I have tried a couple of different things the module that is not found always seems to be the name of the file that is linked to the service in this case service.py.

I have seen that there is am implementation that bypasses the PythonService.exe but there were some warnings attached to that. I just am trying to figure out if anyone has had this problem before and if I am going down the right path. My environment is
Windows Server 2008 R2

Thanks,

Chris Nyland
Tim Roberts
2015-08-26 19:18:52 UTC
Permalink
Post by Nyland, Christopher F CTR USARMY AMSAA (US)
Python could not import the services's module
ImportError: No module named service
%2: %3
I have tried a couple of different things the module that is not found always seems to be the name of the file that is linked to the service in this case service.py.
Services and Network Services each have their own user name, and every
user has its own permissions. It's possible, for example, that your
service.py or the directory it is in is simply not accessible by the
Network Service user name. If you have the file in your
\Users\username\Documents path, that's almost certainly the issue.

Check the file in Explorer to see if it is readable by Everyone.
--
Tim Roberts, ***@probo.com
Providenza & Boekelheide, Inc.
Loading...