Using Python with FME Flow

If you run workspaces from FME Flow that reference Python, the FME Engines must know which Python interpreter to use. Workspaces built with FME Form 2016 or later tell FME which version of Python is required to run Python code through the Python Compatibility workspace parameter.

The Python interpreter that the FME Engines actually use is the one that most closely matches the Python Compatibility workspace parameter, which, by default, is FME’s latest supported version of Python 3. To change the default Python interpreter used by the FME Engines, see Changing the Python Interpreter (Windows only) (below).

Using Additional Python Modules

If you need to reference a Python module from FME Flow that is not part of the Python standard library, follow these steps to: 1) Obtain the module (if you have not already); and 2) Upload the module.

Obtaining the Python Module

If you do not already have the Python module you want to reference, install the package with the following command:

> fme.exe python -m pip install <package_name>

For example, to install a package named PyExecJS:

> fme.exe python -m pip install PyExecJS

This command installs the Python module to the FME shared Python user directory:

C:\Users\<user>\Documents\FME\Plugins\Python\python<XY>

Where <user> is the Windows user name and <XY> is the Python version of the FME Python interpreter.

Uploading the Python Module

  1. In the C:\Users\<user>\Documents\FME\Plugins\Python directory, locate the files or folders of the Python module you installed, such as .pyc or.py files, as well as any sub-directories that may contain init.pyc or main.pyc files of your package.

  2. Use the Upload tool on the Resources page of the Web User Interface, and upload these file(s) and/or folder(s) to the folder under Engine\Plugins\python that corresponds to the Python release compatible with the module (for example, python36).

Changing the Python Interpreter (Windows only)

Important  Consider changing the Python interpreter only if the Python interpreter shipped with FME Flow is incompatible with third-party Python libraries required to run the Python scripts referenced in your workspaces. If you require an Esri ArcGIS Python interpreter to use ArcPy, set the Python Compatibility workspace parameter to the applicable Esri ArcGIS Python 3.x value in FME Workbench prior to uploading to FME Flow. If set properly in this case, changing the Python interpreter explicitly in FME Flow is not necessary.
Note  Beginning with FME Flow version 2019.0 on Linux, changing the Python interpreter is not supported.

Sometimes you will want to use a Python interpreter other than the ones shipped with FME Flow. In that case, you can change the interpreter through the following procedure:

Note  The Python interpreter specified by this procedure does not guarantee the FME Engines will use the interpreter for all workspaces. Instead, the FME Engines use the specified interpreter for all workspaces that have a Python Compatibility value that is compatible with the specified interpreter. If the Python Compatibility of a workspace is not compatible with the specified interpreter, the FME engines use one of their own Python interpreters that is compatible.

Open a command prompt, specifying Run as administrator, and run the following commands:

FME Flow 2018.0 and earlier

<FMEFlowDir>Server/fme/fme.exe APPLY_SETTINGS SYSTEM "Python/Use Custom Python" true

<FMEFlowDir>Server/fme/fme.exe APPLY_SETTINGS SYSTEM "Python/Python Interpreter" c:/<path_to_dll>.dll

Note  For information on how to locate Python dll's (<path_to_dll>), see Choosing a different Python Interpreter in the FME Community.

FME Flow 2018.1 and later

<FMEFlowDir>Server/fme/fme.exe APPLY_SETTINGS SYSTEM "Python/Use Custom Python 64" true

<FMEFlowDir>Server/fme/fme.exe APPLY_SETTINGS SYSTEM "Python/Python Interpreter 64" c:/<path_to_dll>.dll

<FMEFlowDir>Server/fme/fme.exe APPLY_SETTINGS SYSTEM "Python/Custom Python Home 64" c:/<path_to_python_home>

Note  <path_to_python_home> is the installation location of Python.