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. For workspaces built with FME Desktop 2016 or later, the interpreter is determined by the setting of the Python Compatibility workspace parameter. For workspaces built with previous versions of FME Desktop, the interpreter is determined by the Preferred Python Interpreter setting (under Tools > FME Options > Translation).
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 no already have the Python module you want to reference.
- 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/.
- If you installed a Python 2.7 interpreter, you must also install the the pip package management system. (The pip module is included with Python 3.x interpreters.)
- To get pip, securely download the contents of https://bootstrap.pypa.io/get-pip.py.
- From a command prompt, navigate to the directory to which get-pip.py was downloaded.
- Run the command:
- Install the package with the following command:
- 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.
> python get-pip.py
> 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.
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
For workspaces built with FME Desktop 2016 or later, the Python interpreter you want the FME Engines to use must be specified in the workspace, according to the Python Compatibility workspace parameter.
If you have workspaces built in earlier versions of FME Desktop, and you need these workspaces to reference a different Python interpreter than the default version 2.7, follow this procedure:
Windows
Open a command prompt, specifying Run as administrator, and run the following commands:
<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 Knowledge Center.
Linux
Open a command prompt and run the following commands:
<FMEServerDir>Server/fme/fme APPLY_SETTINGS SYSTEM "Python/Use Custom Python" true
<FMEServerDir>Server/fme/fme APPLY_SETTINGS SYSTEM "Python/Python Interpreter" /<path>/libpython2.7.so