Solved

Python does not work when called from a SystemCaller on FME Server 2019.2 and 2020.1.2.1


Badge

I have an environment with FME Server 64 bits 2018.1, and ArcGIS Server 10.7.1

A workspace contains a SystemCaller transformer that is able to run this:

$(PythonEXE) -c "import this".

the parameter PythonEXE is "C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\python.exe"

 

it works ok.

An update to FME Server 2019.2.3 was made, now the execution of the SystemCaller allways fails:

 Update: Same happens in FME Server 2020.1.2.1 with ArcGIS Server 10.8.1

Failed to Execute `""C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\python.exe".....

with this:

 `exit_code' has value `-1073740791'

if I run the same command from a CMD it runs OK

if I run the same command from a Powersehll it runs OK

if I run the same command from a CMD with the credentials used by FME Server it runs OK

if I run the same command from a Powersehll with the credentials used by FME Server it runs OK

 

Is there any configuration or flag that i should activate in order to be able to run ArcGIS Server's python ??

 

 

I was able to reproduce the error in a small scale (see the attached workspace).

It is just a workspace calling the zen of python. the same behavior is observed (see file log_job_46.xml - sorry it is txt file, but I had to rename it)

 

2020-10-06_7-34-21

 

 

icon

Best answer by xtian79 7 October 2020, 09:35

View original

13 replies

Userlevel 4
Badge +26

When you say it runs fine on the CMD are you running it on the same host as the FME Server engine?

After a quick google that ERROR code seems like it could be windows specific?

It's certainly strange that this is failing when run via FME Server.

 

Is FME Desktop installed on that machine? can you test running it on FME Desktop on the same machine?

Badge

When you say it runs fine on the CMD are you running it on the same host as the FME Server engine?

Yes, in the same machine. It is an express installation of FME Server

After a quick google that ERROR code seems like it could be windows specific?

Yes, it could be windows specific, but it happens when python is called from FME SystemCaller

 

Is FME Desktop installed on that machine?

No

can you test running it on FME Desktop on the same machine?

I could try to install the FME desktop on the server

Userlevel 4
Badge +26

When you say it runs fine on the CMD are you running it on the same host as the FME Server engine?

Yes, in the same machine. It is an express installation of FME Server

After a quick google that ERROR code seems like it could be windows specific?

Yes, it could be windows specific, but it happens when python is called from FME SystemCaller

 

Is FME Desktop installed on that machine?

No

can you test running it on FME Desktop on the same machine?

I could try to install the FME desktop on the server

If you run the process in FME Desktop you should see error messages in the log

 

In addition there might be more information in the fme engine log on FME Server. Often system calls are logged there, however, it's not always like that.

 

Anther tip for debugging is to add the console log file on the server. just add ">" and a filepath for a log file output (https://stackoverflow.com/questions/14500616/windows-command-prompt-log-to-a-file)

 

This might give you some more Information apart from the error code

Badge

If you run the process in FME Desktop you should see error messages in the log

 

In addition there might be more information in the fme engine log on FME Server. Often system calls are logged there, however, it's not always like that.

 

Anther tip for debugging is to add the console log file on the server. just add ">" and a filepath for a log file output (https://stackoverflow.com/questions/14500616/windows-command-prompt-log-to-a-file)

 

This might give you some more Information apart from the error code

The attached file log_job_46 is the log from the engine. i took the file from the dark and filthy guts of the server.

Userlevel 4
Badge +26

If you run the process in FME Desktop you should see error messages in the log

 

In addition there might be more information in the fme engine log on FME Server. Often system calls are logged there, however, it's not always like that.

 

Anther tip for debugging is to add the console log file on the server. just add ">" and a filepath for a log file output (https://stackoverflow.com/questions/14500616/windows-command-prompt-log-to-a-file)

 

This might give you some more Information apart from the error code

Oh sorry i mean this one: fmeprocessmonitorengine.log

Badge

If you run the process in FME Desktop you should see error messages in the log

 

In addition there might be more information in the fme engine log on FME Server. Often system calls are logged there, however, it's not always like that.

 

Anther tip for debugging is to add the console log file on the server. just add ">" and a filepath for a log file output (https://stackoverflow.com/questions/14500616/windows-command-prompt-log-to-a-file)

 

This might give you some more Information apart from the error code

Another tip for debugging is to add the console log file on the server. just add ">" and a filepath for a log file output 

For this case it is a better redirection to use:

command > file.txt 2>&1

because we require the standard output and the error output.

 

Userlevel 4
Badge +26

If you run the process in FME Desktop you should see error messages in the log

 

In addition there might be more information in the fme engine log on FME Server. Often system calls are logged there, however, it's not always like that.

 

Anther tip for debugging is to add the console log file on the server. just add ">" and a filepath for a log file output (https://stackoverflow.com/questions/14500616/windows-command-prompt-log-to-a-file)

 

This might give you some more Information apart from the error code

Nice! sounds good

Badge

If you run the process in FME Desktop you should see error messages in the log

 

In addition there might be more information in the fme engine log on FME Server. Often system calls are logged there, however, it's not always like that.

 

Anther tip for debugging is to add the console log file on the server. just add ">" and a filepath for a log file output (https://stackoverflow.com/questions/14500616/windows-command-prompt-log-to-a-file)

 

This might give you some more Information apart from the error code

 

The output from making the call is:

Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
 
Current thread 0x000005a8 (most recent call first):

 

Userlevel 4
Badge +26

If you run the process in FME Desktop you should see error messages in the log

 

In addition there might be more information in the fme engine log on FME Server. Often system calls are logged there, however, it's not always like that.

 

Anther tip for debugging is to add the console log file on the server. just add ">" and a filepath for a log file output (https://stackoverflow.com/questions/14500616/windows-command-prompt-log-to-a-file)

 

This might give you some more Information apart from the error code

Hmmm - seems like a path issue. https://stackoverflow.com/questions/42512817/fatal-python-error-on-windows-10-modulenotfounderror-no-module-named-encodings

Badge

The environment/scope created by FME server  to run the calls, does not include a proper configuration for python, so it is required that the system call includes this:

PATH="C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3;%PATH%"
PYTHONPATH="C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\DLLs;C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\Lib;C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\Lib\site-packages"
PYTHONHOME="C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\"

at leas t in this case that python from ArcGIS server is used.

Badge +9

The environment/scope created by FME server  to run the calls, does not include a proper configuration for python, so it is required that the system call includes this:

PATH="C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3;%PATH%"
PYTHONPATH="C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\DLLs;C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\Lib;C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\Lib\site-packages"
PYTHONHOME="C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\"

at leas t in this case that python from ArcGIS server is used.

Hello @xtian79​ where did you set the configuration? 

Badge

Hello @xtian79​ where did you set the configuration? 

hello @deanhowell​, 

What I am going to tell you is not gonna like you, because it will add a layer of complexity but will solve the issue, or at least for me, it did.

 

I order to use the the system caller I had to create a wrapper that will setup the proper configuration of the  python ESRI's Conda environment, I did it in a PowerShell script:

 

this file is called Invoke-Python.ps1:

param
(    
    [string] 
    $script,    
    [string[]]
    $arguments
)
 
$arcgispro = Get-Item HKLM:\SOFTWARE\ESRI\Server10.9
$pythonPath = Join-Path $arcgispro.GetValue("PythonCondaRoot") -ChildPath "envs\$($arcgispro.GetValue("PythonCondaEnv"))"
$python = Join-Path -Path $pythonPath -childpath "python.exe"
 
$env:PATH = "$pythonPath;$env:path"
$env:PYTHONPATH="$pythonPath\DLLs;$pythonPath\Lib;$pythonPath\Lib\site-packages"
$env:PYTHONHOME = $pythonPath
 
& $python $script $arguments
return $LASTEXITCODE

In the system caller is used:

 

Powershell.exe -c ". """c:\temp\invoke-Python.ps1""" -script """$(PythonScript)""" -arguments """Argument1""","Argument2","""Argument3""","Argument4" "

As you can see there are some arguments with triple quotes those are arguments that include escape characters, i.e. paths with backslash or arguments with quotes.

 

I hope that this helps you.

 

 

 

 

 

Badge +9

Hello @xtian79​ where did you set the configuration?

Thanks @xtian79​ I will see what I can do to get it working. ​

Reply