Is there still fmeobjects package supporting python 2.7 in FME 2022.2?
I need to run an FME workspace in ArcMap, which uses python 2.7 and realized there is no fmeobjects for Python 2 in the FME installation folder. Is there an alternative way to do the job?
Best answer by david_r
Starting with FME 2022.0 and on, Python 2.7 is no longer supported.
You could also use the "subprocess" python module in python 2.7 and run the FME 2022.2 version that way by pointing to the 64bit fme.exe location.
This should allow you to keep using your python 2.7 in desktop and use the new version of FME. Otherwise, to use fmeobjects you would need to follow the advice above.
Here is an example function using the subprocess package:
import subprocess
# Can pull the standard out and error messages for useful workbench feedback.defsub__fmeworker(data):""" command variable object houses the subprocess cmd string line and houses 3 parameters. where data is a python dictionary.
1. _workbench = myworkbench.fmw, 2. data[0] = features to run in the workbench, 3. data[1] = log path .txt
The subprocess.Popen() executes the command and retrieves the process outputs to stdout and stderr."""
text = ''try:
fme_ = r"C:\Program Files\FME\fme.exe"##fme.exe
command = f'"{fme_}" "{_Workbench}" --FEATURE_TYPES "{data[0]}" --LogFile "{data[1]}"'
starter = subprocess.STARTUPINFO()
starter.dwFlags |= subprocess.STARTF_USESHOWWINDOW
process = subprocess.Popen(command,startupinfo=starter, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
if stderr:
stderr_de = str(stderr.decode("utf-8")) # Need to remove byte object
msg = stderr_de.split("\r\n")[0]
text += data[0] +' '+ msg
else:
stdout_de = str(stdout.decode("utf-8")) # Need to remove byte object
msg = stdout_de.split("\r\n")
text += msg+'ERROR########'except: #if the workbench fails add error tag
text += data[0]+'ERROR########'return text
Another option would be to create a .bat file with your workbench information and then you can run it in python by just doing a subprocess.call(). I had to use both of these workarounds for a couple projects since the clients still use Desktop and have not migrated to PRO but want the newest fme version.
Example .bat:
REM %1 and %2 are arguments - workbench parameters (if you need those) ## this is a comment
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.