Solved

using arcpy in python caller in fme 2019.1: issues with python version and module not found error

  • 6 February 2020
  • 2 replies
  • 34 views

Badge +1

I am attempting to use the arcpy module in the python caller transformer in FME workbench 2019. I am using 64 bit FME 2019.1 build (19643), ArcGIS Desktop 10.6.1 with 64 bit background processing installed. I am wondering if there are any suggestions to getting my workbench to successfully access the arcpy module so I can use Esri GP tools inside my PythonCaller transformer.

 

I have tried the following settings for preferred python interpreter and python home:

0684Q00000ArBnOQAV.png

when using this setting it appears that it defaults to FME Python 3.7, the following messages appear to show this in my translation log:

0.0|INFORM|Loaded module 'PythonFactory' from file 'C:\Program Files\FME_2019.1.3.1\plugins/PythonFactory.dll'
0.0|INFORM|FME API version of module 'PythonFactory' matches current internal version (3.8 20190621)
0.0|INFORM|Using Python interpreter from `C:\Program Files\FME_2019.1.3.1\fmepython37\python37.dll' with PYTHONHOME `C:\Program Files\FME_2019.1.3.1\fmepython37'
0.0|INFORM|Python version 3.7 loaded successfully

 

And the following errors are returned:

0.3|ERROR |Python Exception <ModuleNotFoundError>: No module named 'arcpy'
0.0|ERROR |Error executing string ...**my code snippet here**
0.0|FATAL |Factory proxy not initialized
0.0|FATAL |PythonCaller (PythonFactory): PythonFactory failed to process feature
0.0|ERROR |A fatal error has occurred. Check the logfile above for details
0.0|INFORM|Translation FAILED with 5 error(s) and 0 warning(s) (0 feature(s) 

0684Q00000ArBqIQAV.png

or

0684Q00000ArBohQAF.png

when using this setting it explicitly states that it is ignoring the specified python library, the following messages appear to show this in my translation log:

0.0|WARN  |The workspace requires Python version 3.7. Ignoring user-specified Python library `C:\Windows\System32\python27.dll'
0.0|INFORM|Using Python interpreter from `C:\Program Files\FME_2019.1.3.1\fmepython37\python37.dll' with PYTHONHOME `C:\Program Files\FME_2019.1.3.1\fmepython37'
0.0|INFORM|Python version 3.7 loaded successfully

and the same errors returned above appear because it has defaulted to FME Python 3.7

I also tried pointing to the python27.dll in the 64 bit windows folder:

0684Q00000ArBqJQAV.png

and

0684Q00000ArBk2QAF.png

and received he following messages in my translation log:

0.0|WARN  |The User-specified library C:\Windows\SysWOW64\python27.dll could not be loaded
0.0|INFORM|Using Python interpreter from `C:\Program Files\FME_2019.1.3.1\fmepython37\python37.dll' with PYTHONHOME `C:\Program Files\FME_2019.1.3.1\fmepython37'
0.0|INFORM|Python version 3.7 loaded successfully

I got identical errors to the above examples related to a missing module as it was loading the FME python.

I also have ArcGIS Pro 2.3 installed so I attempted to use the following as well

0684Q00000ArBktQAF.png

here it appears to load FME Python 3.7 without even trying to use the ArcGIS Pro python

0.0|INFORM|Loaded module 'PythonFactory' from file 'C:\Program Files\FME_2019.1.3.1\plugins/PythonFactory.dll'
0.0|INFORM|FME API version of module 'PythonFactory' matches current internal version (3.8 20190621)
0.0|INFORM|Using Python interpreter from `C:\Program Files\FME_2019.1.3.1\fmepython37\python37.dll' with PYTHONHOME `C:\Program Files\FME_2019.1.3.1\fmepython37'
0.0|INFORM|Python version 3.7 loaded successfully

My code snippet (although it doesnt seem to matter yet since it cant even load the library/module) is as follows:

 

import fme
import fmeobjects
import arcpy

# Overwrite output feature class
arcpy.env.overwriteOutput=True

def processFeature(feature):
    dataset = feature.getAttribute('_dataset')
    arcpy.env.workspace = dataset
    
    #Intersect
    arcpy.Intersect_analysis("ic_pilot_check",dataset + "/" + "ic_pilot_intersect", "ALL" , "" , "INPUT")
icon

Best answer by lauraatsafe 6 February 2020, 20:17

View original

2 replies

Badge +9

Hi @kschilly,

Have you tried changing the Python Compatibility setting within the workspace itself? That option is located in the Navigator Window under Workspace Parameters > Scripting:

 

Try changing that to use Esri ArcGIS Pro Python 3.6 and then re-running the workspace. Does that pick up the correct interpreter?

The Python Compatibility setting within the navigator is what will control which interpreter FME tries to load when running any Python within the workspace and will override anything set in the Preferred Python Interpreter setting configured in FME Options.

Badge +1

Hi @kschilly,

Have you tried changing the Python Compatibility setting within the workspace itself? That option is located in the Navigator Window under Workspace Parameters > Scripting:

 

Try changing that to use Esri ArcGIS Pro Python 3.6 and then re-running the workspace. Does that pick up the correct interpreter?

The Python Compatibility setting within the navigator is what will control which interpreter FME tries to load when running any Python within the workspace and will override anything set in the Preferred Python Interpreter setting configured in FME Options.

That did the trick! Thank you so much for your help, saved me a lot of time.

Reply