Run an FME Workspace from Python using FMEWorkspaceRunner

FME Form Support
FME Form Support
  • Updated

Introduction

To run an FME workspace using Python outside FME Workbench, you can edit the attached sample and include it within your Python script. For example, an ArcGIS geoprocessing script written in Python could launch an FME Workspace to preprocess or translate data.

Requirements

  • You must have FME Form (formerly FME Desktop) installed on the machine running the Python script.
  • You need to know the path to your FME workspace and the required published parameters for it. For information on creating and modifying published parameters within your workspace, see the documentation.
  • If you are using a Python installation that is not the one provided by FME, then you must ensure the Python version is compatible with the version of FME used.
  • You need to add the path to the fmeobjects modules by including it in an environment variable called PYTHONPATH or by adding the path to fmeobjects directly within your Python script. 
    • If using FME 2023.2 and newer, the path to the fmeobjects module is: <FMEInstallDirectory>\python. For example:
import sys 
sys.path.append(r"C:\Program Files\FME\python")
  • If using FME 2023.1 and older, add path to the fmeobjects module (<FMEInstallDirectory>\fmeobjects\python<major><minor>) within your Python search path. For example:
import sys
sys.path.append(r"C:\Program Files\FME\fmeobjects\python310")

Script

The script below runs your workspace with the specified parameters and returns either a success message or an FME Exception. Download the attached version of the script to better preserve indentations, etc. Edit the path to the workspace where you see the workspace variable and the published parameters names and values, where you see the parameters dictionary being created to reflect your own environment.

The script uses the FMEWorkspaceRunner class and the runWithParameters() method found within fmeobjects. You can also use the promptRun() method to prompt for published parameters by uncommenting the appropriate line below.

This script contains Python 3-specific syntax and may fail when run in Python 2.

import sys, os

# Modify the path if FME is installed in another location
sys.path.append(r"C:\Program Files\FME\python")
os.environ['FME_HOME'] =r"C:\Program Files\FME"

import fmebootstrap
import fmeobjects

# initiate FMEWorkspaceRunner Class
runner = fmeobjects.FMEWorkspaceRunner()

# Full path to Workspace, example comes from the FME 2020 Training Dataset
workspace = r"C:\FMEData2020\Workspaces\IntroToDesktop\Ex2.1-Complete.fmw"

# Set workspace parameters by creating a dictionary of name value pairs
parameters = {}
parameters["SourceDataset_XLSXR"] ="https://s3.amazonaws.com/FMEData/Interopolis/CaseLocationsDetails_2017_XLS.zip"
parameters['DestDataset_CSV2'] = r"C:\FMEData2020\Output\Training"

# Use try-except block so we can get FME Exception
try:
    # Run Workspace with parameters set in above dictionary
    runner.runWithParameters(workspace, parameters)
    
    # Or use promptRun to prompt for published parameters
    # runner.promptRun(workspace)
    
    # Tell user the workspace ran
    print(f"The Workspace: {workspace}")
    print("...ran successfully")
    
except fmeobjects.FMEException as ex:
    # Print out FME Exception if worskspace failed
    print(ex.message)

# get rid of FMEWorkspace runner so we don't leave an FME process running
runner = None

Installed Example

An "official" example of running a workspace with Python can be found in the FME installation folder (e.g., C:\Program Files\FME\fmeobjects\samples\Python\WorkspaceRunner.py) if the Install SDK option was selected during FME installation.

Find all the workspace running options for the Python interface in the FME documentation at: fmeobjects.FMEWorkspaceRunner Documentation 

Was this article helpful?

We're sorry to hear that.

Please tell us why.

As of January 14th, 2026, comments on knowledge base articles have been closed. To make sure questions don’t get missed and to enable more community support, we’ve moved discussions to the FME Community. If you have a question or a comment about this article, please create a new post or create a support ticket.