Reputation: 371
I'm trying to debug my service with PythonService.exe
and I get a strange error:
PS C:\Users\rs_al\Dev\PyXLSQL> py serviceapp.py install
Installing service pyxlsql
Changing service configuration
Service updated
PS C:\Users\rs_al\Dev\PyXLSQL> py serviceapp.py debug
Debugging service pyxlsql - press Ctrl+C to stop.
Error 0xC0000004 - Python could not import the service's module
ModuleNotFoundError: No module named 'w32service'
(null): (null)
Project structure
serviceapp.py
w32service\
__init__.py
service.py
And if I move whole code from service.py
into serviceapp.py
I can debug it without issues.
EDIT:
gui.py
gui\
__init__.py
menu.py
pageone.py
pagetwo.py
pagethree.py
And it perfectly works as *.py
or .*exe
Upvotes: 1
Views: 807
Reputation: 41187
Python interpreter doesn't know where to look for your w32service module (package). One way would be to add its path to [Python 3.Docs]: Modules - The Module Search Path (before importing it):
import sys
import os
sys.path.append(os.path.abspath(os.path.dirname(__file__)))
from w32service.service import WinService
# ...
To make things clearer, use print(sys.path)
before importing anything (well, except sys) to see where is the Python searching for modules.
Upvotes: 1