Using Python with FME Server

If you run workspaces from FME Server that reference Python, the FME Engines must know which Python interpreter to use. Workspaces built with FME Desktop 2016 or later tell FME which version of Python is required to run Python code through the Python Compatibility workspace parameter. For workspaces built before FME Desktop 2016, the Python Compatibility option is not available, and FME assumes any Python code referenced in the workspace requires a Python 2.7 interpreter.

The Python interpreter that the FME Engines actually use is the one that most closely matches the Python Compatibility workspace parameter. By default, it is one of the Python interpreters that ships with FME Server—Python 2.7 or FME’s latest supported version of Python 3. For example, if Python Compatibility for the workspace is set to Python 2.7, FME loads the Python 2.7 interpreter that ships with FME Server. If Python Compatibility is set to Python 3.5+, the FME Engines load the Python 3.x interpreter that ships with FME Server (where "x" is the latest supported version). 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 Server 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

Follow these steps if you do not already have the Python module you want to reference.

  1. To run a Python module, you must reference your own Python interpreter. If you do not have a Python interpreter installed, install one for the applicable version—either Python 2.7 or Python 3.x—from https://www.python.org/downloads/.
  2. If you installed a Python 2.7 interpreter, you must also install the pip package management system. (The pip module is included with Python 3.x interpreters.)
    1. To get pip, securely download the contents of https://bootstrap.pypa.io/get-pip.py.
    2. From a command prompt, navigate to the directory to which get-pip.py was downloaded.
    3. Run the command:
    4. > python get-pip.py

  3. Install the package with the following command:
  4. > python -m pip install <package_name> --target C:\Users\<user>\Documents\FME\Plugins\Python

    For example, to install a package named PyExecJS:

    > python -m pip install PyExecJS --target C:\Users\<user>\Documents\FME\Plugins\Python

    Note: Substitute <user> with the Windows user name.

  5. From the C:\Users\<user>\Documents\FME\Plugins\Python directory, locate any *.pyc files and the sub-directory that contains the init.pyc and main.pyc files of your package. These files make up the Python module.

Uploading the Python Module

Use the Upload tool on the Resources page of the Web User Interface, and upload it to the folder under Engine\Plugins\python that corresponds to the Python release compatible with the module (for example, python27).

Changing the Python Interpreter (Windows only)

Note: Beginning with FME Server 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 Server. 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 Server 2018.0 and earlier

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

<FMEServerDir>Server/fme/fme.exe APPLY_SETTINGS SYSTEM "Python/Python Interpreter" c:/<path_to_dll>/python27.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 Server 2018.1 and later

<FMEServerDir>Server/fme/fme.exe APPLY_SETTINGS SYSTEM "Python/Use Custom Python <32|64>" true

<FMEServerDir>Server/fme/fme.exe APPLY_SETTINGS SYSTEM "Python/Python Interpreter <32|64>" c:/<path_to_dll>/python27.dll

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

Note: For <32|64>, specify 32 for 32-bit FME Server and 64 for 64-bit FME Server.

<path_to_python_home> is the installation location of Python.