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
-
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.
-
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)
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:
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
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>