Skip to main content
Solved

Python Integration


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

 

Best answer by debbiatsafe

debbiatsafe wrote:

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.environ['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?

View original
Did this help you find an answer to your question?

9 replies

geogaard
Contributor
Forum|alt.badge.img+15
  • Contributor
  • August 2, 2022

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.


  • Author
  • August 2, 2022
geogaard wrote:

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.


geogaard
Contributor
Forum|alt.badge.img+15
  • Contributor
  • August 17, 2022
sondre wrote:

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 :(


debbiatsafe
Safer
Forum|alt.badge.img+20
  • Safer
  • August 31, 2022

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?


debbiatsafe
Safer
Forum|alt.badge.img+20
  • Safer
  • Best Answer
  • September 9, 2022
debbiatsafe wrote:

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.environ['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?


  • Author
  • January 9, 2023

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. 


dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • January 9, 2023
sondre wrote:

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)


  • Author
  • January 9, 2023
dustin wrote:

@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!


  • Author
  • January 9, 2023
debbiatsafe wrote:

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.environ['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?

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

Thanks!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings