A high-level overview of how and where Python may be applied in FME.
Where Python can be used in FME¶
There are three main places where Python can be used in FME:
- The PythonCreator transformer lets you write Python code to create new features.
- The PythonCaller transformer lets you write Python code to manipulate existing features in a pipeline.
- Each workspace can define Python scripts that run before or after workspace execution. These startup and shutdown scripts can be found in Navigator > Workspace Parameters > Scripting.
Python can also be used to create custom readers, writers, and transformers. Some of the readers, writers, and transformers included with FME rely on Python.
Python 2.7 is supported in FME 2016 and earlier. Python 2.7, 3.4, and 3.5 are supported from FME 2017 to 2018.1. Python 2.7 (deprecated), 3.5, 3.6, and 3.7 are supported as of FME 2019.0.
On Windows, the FME 2019.0 installation includes both Python 2.7 (optional component) and 3.7. On Mac, the FME 2019.0 installation includes Python 3.7. On Linux, FME uses the system Python interpreter.
In FME 2019.0, Python 3.7 is the default interpreter. FME’s preferred Python interpreter can be set in Tools > FME Options > Translation. Each workspace also has a setting for its preferred or required Python versions. It can be found in Navigator > Workspace Parameters > Scripting > Python Compatibility. This setting in the workspace takes precedence over FME Options. All Python code executed by the workspace will run with the selected interpreter.
FME supports using the Python interpreter that’s included with ArcGIS Desktop and ArcGIS Pro, which grants access to the arcpy library.
To minimize compatibility issues when sharing workspaces, it’s strongly recommended that your Python code be written such that it supports both Python 2 and 3.