Using Python with FME Server
Configuring a Custom Python Interpreter
Windows
On Windows systems, FME installs its own Python interpreter, which is used by any scripts that run Python in FME. If you want FME to use your own custom Python interpreter, run the following commands from a command prompt:
Note: To avoid errors, the Windows Command Prompt must likely be run as administrator, even if you are currently running your machine with administrator privileges. From the Start Menu, right-click on Command Prompt and select Run as administrator.
<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
For information on how to locate Python dll's (<path_to_dll>), see Choosing a different Python Interpreter in the FME Knowledge Center.
Linux
On Linux, FME uses the Python module that is installed with the system. To use your own Python module in FME, configure it with the system Python:
<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
Uploading Python Modules to FME Server
If you have a Python module you need to use on FME Server which is not part of the Python standard library, 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).
Uploading Python Packages
If you want to upload a Python package, rather than a stand-alone module, follow this procedure:
- Install the package to FME Desktop. Safe recommends using the pip package management system for this task.
- 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:
- To install a package, run the following command:
> fme 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.
- From the directory specified in step 1d, locate the sub-directory that contains the init.pyc and main.pyc files of your package.
- Use the Upload tool on the Resources page of the FME Server Web User Interface, as described above, and upload the directory containing the corresponding .pyc files of the package.