You are here: Administrator's Guide > Other Common Tasks > Licensing and Administration > Configuring the FME Engine > Using Python with FME Server

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 thePython Compatibilityworkspace 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, ifPython Compatibilityfor the workspace is set toPython 2.7, FME loads the Python 2.7 interpreter that ships with FME Server. IfPython Compatibilityis set toPython 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, seeChanging the Python Interpreter(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. 运行Python模块,必须参考你的噢n 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—fromhttps://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. 运行以下命令:
    4. > python get-pip.py

  3. 与foll安装包owing 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 theResourcespage 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

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 aPython Compatibilityvalue that is compatible with the specified interpreter. If thePython Compatibilityof a workspace is not compatible with the specified interpreter, the FME engines use one of their own Python interpreters that is compatible.