Skip to main content

When I call the function convert I wrote, I get the error "PythonNameError: global name 'convert' is not not defined"

How did you define "convert" in your Python code?

Also, have you looked at the PythonCaller documentation?


Additional Python libraries needs to be installed in your FME instances, typically under (FME_HOME)/python/python27 (for old Python). Each library needs to include the standard "__init__.py" file to be recognized, afaik.

Have a look at the standard libraries installed.

If it's for a custom transformer, a companion PY file stored side-by-side will also do the trick.


How did you define "convert" in your Python code?

Also, have you looked at the PythonCaller documentation?

 

a simple function

 

def convert():

 

FMELogFile().logMessageString('ddd')

 

This function is defined in the class FeatureProcessor(object) and is called inside the close() function.

You need to make it a class method, since you're using it as part of an object (class instance). For example, inside the FeatureProcessor definition:

def convert(self):
    FMELogFile().logMessageString('ddd') 

Notice the "self" parameter. Then in the close() function you write:

 

self.convert()


For more information, see the Python documentation on how to define class methods.

This tutorial is also pretty helpful: https://www.learnpython.org/en/Classes_and_Objects


Reply