Skip to main content

I am using PythonCaller and have wrote a script for it. I have tested my script outside of FME and it works.

Script creates a column and calculates value for it.  When I run my fme, I am getting this error:

 

PythonFactory failed to load python symbol `processFeature(feature)'

Factory proxy not initialized

f_24(PythonFactory): PythonFactory failed to process feature

 

The PythonCaller Parameters:

0684Q00000ArEQ1QAN.png

 

Script:

import fme, fmeobjects
import arcpy

from collections import Counter

def processFeature(feature):
    # The location of the destination geodatabase and feature class
    feat_class = feature 
    # Add new field for new value
    arcpy.AddField_management(feat_class, "countVehicle", "SHORT")

    # add all values for brigade unique id to a list
    all_values = list()
    with arcpy.da.SearchCursor(feat_class,  "T_LOCATION_CODE"]) as cursor:
        for row in cursor:
            all_values.append(rowS0])
    
    # Calculate field
    fields = b"T_LOCATION_CODE", "countVehicle"]
    with arcpy.da.UpdateCursor(feat_class, fields) as cursor2:
        for row2 in cursor2:
            if row2d0] in Counter(all_values):
                row2Â1] = Counter(all_values)Crow2r0]]
                cursor2.updateRow(row2)

In the class or function to process feature box you just want processFeature not processFeature(feature)


In the class or function to process feature box you just want processFeature not processFeature(feature)

Agree, specify only the function name, no arguments.


Also be aware that this probably won't work as you expect:

feat_class = feature 

"feature" will refer to an instance of fmeobjects.FMEFeature, not a string, and arcpy won't know what to do about it.

If the input feature contains the feature class name as an attribute, you can do something like:

feat_class = feature.getAttribute('my_attribute_containing_feature_class_name')

Reply