How to Add Python to external interpreter on Windows V11

Document ID : KB000088646
Last Modified Date : 14/04/2018
Show Technical Document Details
Issue:
How do you add Python as an external interpreter in the Automation Engine?
Resolution:
Add this to the REGISTER_VARIABLE.WINDOWS in client 0: 
:set &uc_register_varname = sys_last_registered_varname() 
:set &uc_register_valuename = sys_last_registered_valuename() 
:set &uc_register_otype# = sys_act_me_type() 
:if &uc_register_otype# = 'JOBS' 
: set &uc_windows_typ = get_att(win_typ) 
: if &UC_WINDOWS_TYP = "BAT" 
: IF &$EXT_INTERPRETER# = 'PYTHON' 
: SET &UC_PATH_JOBMD# = STR_SUB("&UC_JOBMD", "\", "\\") 
import subprocess 

try: 
command = "&UC_PATH_JOBMD# JNR=&UC_REALNR MNR=&UC_MANDANT PNR=&UC_IP_PORT IPA=&UC_IP_ADR TYP=V VTYPE=T NAME=&uc_register_varname VALUE=\"%s\" " % (&uc_register_valuename, ) 
retcode = subprocess.call(command, shell=True) 
if retcode < 0: 
print("Child was terminated by signal", -retcode) 
else: 
print("Child returned", retcode) 
except OSError as e: 
print("Execution failed:", e) 

: else 
&UC_JOBMD JNR=&UC_REALNR MNR=&UC_MANDANT PNR=&UC_IP_PORT IPA=&UC_IP_ADR TYP=V VTYPE=T NAME=&uc_register_varname VALUE="&uc_register_valuename" 
: endif 
: endif 
:endif

Next in the UC_EXT_INTERPRETERS_WINDOWS in client 0:
Key: Python
Value 1: .py
Value 2: path to python executable

In the Job:
: define &PYTHONVAR#, String
:BEGIN_EXT_INT PYTHON

<Python script>
:REGISTER_VARIABLE "PYTHONVAR#", "helloworld"
:END_EXT_INT PYTHON
:PRINT "PYTHONVAR: '&PYTHONVAR#'"