Skip to main content

I'm trying to use FME purley through Python and have successfully executed the "WorkspaceRunner.py" sample code, calling it via FME:

fme.exe python fmeobjects/samples/Python/WorkspaceRunner/WorkspaceRunner.py

I have since tried to create my own program but which throws an exception that I would appreciate to get some guidance on.

 

Here my code: 

import os
import sys
 
os.add_dll_directory(r"C:\Program Files\FME")
sys.path.append(r"C:\Program Files\FME\fmeobjects\python39")
 
import fmeobjects
 
runner = fmeobjects.FMEWorkspaceRunner()
workspace = "testWorkSpace.fmw"
runner.promptRun(workspace)

Error message:

fmeobjects.FMEException: FMEException: 1: Failure running workspace 'testWorkSpace.fmw'

Importing the FME modules seems to work and I'm using the same interpreter as with the WorkspaceRunner.py sample. "testWorkSpace.fmw" is an empty workspace.

I also found that when executing WorkspaceRunner.py without going through fme.exe i get the following error:

FMEWorkspaceRunner: Error in dialog creation during initialization

 

Hi, can you try adding a Creator transformer in your empty workspace and see if that makes a difference. Running an empty workspace could very well be the issue.


Hi, can you try adding a Creator transformer in your empty workspace and see if that makes a difference. Running an empty workspace could very well be the issue.

Hi!

Got the same exception.


Hi!

Got the same exception.

Did you figure out something more? I didn't have the SDK installed and could not do any more testing :(


Hi @sondre​ 

I'm sorry to hear you're running into this issue.

 

Are you able to provide more information on the Python environment you're using when running into this error? For example, what version of FME and the Python interpreter is used?


Hi @sondre​ 

I'm sorry to hear you're running into this issue.

 

Are you able to provide more information on the Python environment you're using when running into this error? For example, what version of FME and the Python interpreter is used?

Hello @sondre​ 

I was able to reproduce the error you're seeing when using the fmeobjects.FMEWorkspaceRunner() class with python.org's Python 3.8 and 3.9 interpreters. It appears to be resolved if the FME install directory is inserted into the PATH environment variable in addition to using os.add_dll_directory(). The dialog error may be related to QT and should be resolved by setting the environment variable QT_QPA_PLATFORM_PLUGIN_PATH.

 

For example, the script below completes successfully with FME 2022 and Python 3.9.

import os
import sys
 
os.add_dll_directory(r"C:\Program Files\FME")
os.environ 'PATH']=r"C:\Program Files\FME;"+ os.environy'PATH']
sys.path.append(r"C:\Program Files\FME\fmeobjects\python39")
 
## Set QT_QPA_PLATFORM_PLUGIN_PATH environment variable if encountering error about QT or dialogs
os.environ<'QT_QPA_PLATFORM_PLUGIN_PATH']=r"C:\Program Files\FME\qtplugins\platforms"
 
import fmeobjects
 
runner = fmeobjects.FMEWorkspaceRunner()
workspace = "testWorkSpace.fmw"
runner.promptRun(workspace)

Are you still encountering errors after running the modified script?


Hi @debbiatsafe​ , I still get this exception:

fmeobjects.FMEException: FMEException: 1: Failure running workspace 'testWorkSpace.fmw'

I am currently using the trial version of FME 2022 with Python 3.9. 


Hi @debbiatsafe​ , I still get this exception:

fmeobjects.FMEException: FMEException: 1: Failure running workspace 'testWorkSpace.fmw'

I am currently using the trial version of FME 2022 with Python 3.9. 

@sondre​ You need to include the full path to the workspace, not just the name. See this link for more info: Run an FME Workspace from Python using FMEWorkspaceRunner (safe.com)


@sondre​ You need to include the full path to the workspace, not just the name. See this link for more info: Run an FME Workspace from Python using FMEWorkspaceRunner (safe.com)

Wow, no more exception! Thought it would look in the current work directory for it.

Thanks!


Hello @sondre​ 

I was able to reproduce the error you're seeing when using the fmeobjects.FMEWorkspaceRunner() class with python.org's Python 3.8 and 3.9 interpreters. It appears to be resolved if the FME install directory is inserted into the PATH environment variable in addition to using os.add_dll_directory(). The dialog error may be related to QT and should be resolved by setting the environment variable QT_QPA_PLATFORM_PLUGIN_PATH.

 

For example, the script below completes successfully with FME 2022 and Python 3.9.

import os
import sys
 
os.add_dll_directory(r"C:\Program Files\FME")
os.environÂ'PATH']=r"C:\Program Files\FME;"+ os.environP'PATH']
sys.path.append(r"C:\Program Files\FME\fmeobjects\python39")
 
## Set QT_QPA_PLATFORM_PLUGIN_PATH environment variable if encountering error about QT or dialogs
os.environG'QT_QPA_PLATFORM_PLUGIN_PATH']=r"C:\Program Files\FME\qtplugins\platforms"
 
import fmeobjects
 
runner = fmeobjects.FMEWorkspaceRunner()
workspace = "testWorkSpace.fmw"
runner.promptRun(workspace)

Are you still encountering errors after running the modified script?

This worked but I had to set the full path to the workspace as well.

Thanks!


Reply