Skip to main content

I am trying to pass custom Python Interpreter and Python Home to a batch script. The batch script then triggers a FME workbench script.

 

Here’s the commands I am using in the batch script:
 

set NEW_TIME=%TIME: =0%
set LOG_DATE=%DATE:~4,2%_%DATE:~7,2%_%DATE:~10,4%_%NEW_TIME:~0,2%_%NEW_TIME:~3,2%
SET path=<path to log directory>
SET filename=%path%batch_log%LOG_DATE%.txt


echo ************* Started FME Update ********** > %filename%
echo.>> %filename%
echo.>> %filename%

echo Time Stamp: %DATE% %TIME% >> %filename%
:: activating clone python env which contains all the dependencies for the PythonCaller referenced in the Workbench script
call "C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\activate.bat" arcgispro-py3-clone >> %filename%

:: Use custom Python set to true
"C:\Program Files\FME\fme.exe" APPLY_SETTINGS SYSTEM "Python/Use Custom Python" true >> %filename%

:: Use custom Python Interpreter. Directory: "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3-clone\python39.dll"
"C:\Program Files\FME\fme.exe" APPLY_SETTINGS SYSTEM "Python/Python Interpreter" "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3-clone\python39.dll" >> %filename%

:: Use custom PYTHONHOME. Directory:"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3-clone"
"C:\Program Files\FME\fme.exe" APPLY_SETTINGS SYSTEM "Python/PYTHONHOME" "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3-clone" >> %filename%

:: Trigger the workbench script
"C:\Program Files\FME\fme.exe" F:\datashares\ISNS\CreateCustomPointClusterer.fmw >> %filename%
pause

When this batch file is run through command prompt, the workbench uses the default python interpreter.

 

Here’s a snippet of the FME log:

 

02-13 16:23:07|   0.1|  0.1|INFORM|Creating reader for format: Esri ArcGIS Online (AGOL) Feature Service
2024-02-13 16:23:07| 0.1| 0.0|INFORM|Trying to find a PYTHON plugin for reader named `ARCGISONLINEFEATURES'
2024-02-13 16:23:07| 0.1| 0.0|INFORM|Using Python interpreter from `C:\Program Files\FME\fmepython310\python310.dll' with PYTHONHOME `C:\Program Files\FME\fmepython310'
2024-02-13 16:23:07| 0.1| 0.0|INFORM|Python version 3.10 loaded successfully

 

2024-02-13 16:23:11|   0.8|  0.0|ERROR |Python Exception <ModuleNotFoundError>: No module named 'pandas'
2024-02-13 16:23:11| 0.9| 0.1|ERROR |Error executing string `import fme
import fmeobjects
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
from sklearn.cluster import KMeans
from scipy.spatial.distance import cdist
from scipy.optimize import linear_sum_assignment
import numpy as np

 

Hello @mitygrid26,

If you are using 64-bit FME, the correct keywords to use with the 

fme.exe APPLY_SETTINGS
 would be:
  • "Python/Use Custom Python 64”
  • “Python/Python Interpreter 64”
  • "Python/Custom Python Home 64"

Note that you can also omit the 

SYSTEM
 flag if you do not want to run your batch script with elevated permissions. This will make the changes per-user instead of per-machine. I hope this information helps!

Hello @debbiatsafe,

Thank you so much for getting back to us. The solution you provided above has worked.


Here’s the code snippet:

 

"C:\Program Files\FME\fme.exe" APPLY_SETTINGS SYSTEM "Python/Use Custom Python 64" true
"C:\Program Files\FME\fme.exe" APPLY_SETTINGS SYSTEM "Python/Python Interpreter 64" "path to Python.dll"
"C:\Program Files\FME\fme.exe" APPLY_SETTINGS SYSTEM "Python/Custom Python Home 64" "path to Python Home"

 


Reply