Python Run Script Tasks Failing on Windows Computers
search cancel

Python Run Script Tasks Failing on Windows Computers

book

Article ID: 225064

calendar_today

Updated On:

Products

Client Management Suite

Issue/Introduction

When targeting a Windows computer where Python is installed with a Run Script task with Script type set to Python Script, the task fails with a return code of 2.

The script task succeeds if targeting a Linux computer with Python installed. 

Environment

ITMS 8.6 RU1

Cause

Patch variable incorrectly set during installation of Python and/or the installation was set to default and the path is inside the User area.

Resolution

Locate the path to Python.exe. In testing, this was set to Program Files instead of the default, and Python.exe was in Program Files\Python\Python39.

At a command prompt, run:

set PATH=%PATH%;C:\Program Files\Python\Python39

Python run script tasks then ran successfully

In another instance, the user installed Python using the default path, which would be C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python39. 

Because of this, the script task would fail with exit code 2. Setting the script task > Advanced option to run as the logged on user allowed the script task to run successfully.