O'Reilly logo

Python Programming On Win32 by Mark Hammond, Andy Robinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Installing, Debugging, and Running a Python Service

Now that we have a service written in Python, what to do with it? This section discusses installing the service, debugging the service, and starting and stopping the service.

Installing the service

As discussed previously, an application named PythonService.exe hosts all Python services. This executable must be registered before you can install the service. The registration process need only be run once per machine, regardless of how many services the program hosts. The installation package for the Python for Windows extensions automatically registers this, but the information is included here for completeness. To register PythonService.exe, perform the following steps:

  1. Start a command prompt.

  2. Change to the directory containing PythonService.exe, typically \Program Files \Python\win32.

  3. Execute the command:

    C:\Program Files\Python\win32>PythonService.exe /register
    Registering the Python Service Manager...
    C:\Program Files\Python\win32>

Now to install the service, perform the following steps:

  1. Start a command prompt.

  2. Change to the directory containing the Python source code that implements the service.

  3. Execute the command:

    C:\Scripts> SmallestService.py install
    Installing service SmallestPythonService to Python class 
       C:\Scripts\SmallestService.SmallestPythonService
    Service installed
    C:\Scripts>

The service is now installed and ready to run. To confirm the service has been correctly installed, use the control panel to start the Services applet ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required