Using Python withFME Flow
If you runworkspaces fromFME Flowthat reference Python, the FME Engines must know which Python interpreter to use.Workspaces built withFME Form2016 or later tell FME which version of Python is required to run Python code through thePython Compatibilityworkspaceparameter.
The Python interpreter that the FME Engines actually use is the one that most closely matches the Python Compatibilityworkspaceparameter, which, by default, is FME’s latest supported version of Python 3. To change the default Python interpreter used by the FME Engines, seeChanging the Python Interpreter (Windows only)(below).
Using Additional Python Modules
If you need to reference a Python module fromFME Flowthat 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>的Python版本FME Python宰相ter.
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 theResourcespage 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 withFME Flow. In that case, you can change the interpreter through the following procedure:
Open a command prompt, specifyingRun as administrator, and run the following commands:
FME Flow2018.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 Flow2018.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:/
<FMEFlowDir>Server/fme/fme.exe APPLY_SETTINGS SYSTEM "Python/Custom Python Home 64" c:/<path_to_python_home>