Skip to main content
Solved

python caller error

  • August 13, 2024
  • 6 replies
  • 118 views

soly
Contributor
Forum|alt.badge.img+3

Hello , 

I got error from Python caller .

i would like to get all paths from start node to end node then I have written this script but I got Ann error .

 

could you please help me to fix this problem ?

import fme

import fmeobjects

import networkx as nx


class FeatureProcessor(object):

def __init__(self):

self.graph = nx.DiGraph()

self.start_end_pairs = []


def input(self, feature):

start_node = feature.getAttribute('start_node')

end_node = feature.getAttribute('end_node')

arc_id = feature.getAttribute('arc_id')



self.graph.add_edge(start_node, end_node, arc_id=arc_id)

self.start_end_pairs.append((start_node, end_node))


def find_all_paths(self, start, end):

return list(nx.all_simple_paths(self.graph, source=start, target=end))


def close(self):

for start, end in self.start_end_pairs:

all_paths = self.find_all_paths(start, end)

for path in all_paths:

feature = fmeobjects.FMEFeature()

feature.setAttribute('path', ' -> '.join(path))

self.pyoutput(feature)

 

Python Exception <AttributeError>: module 'importlib.resources' has no attribute 'files'

Error executing string `import fme

Error :

Factory proxy not initialized

PythonCaller_3 (PythonFactory): PythonFactory failed to process feature

PythonCaller_3 (PythonFactory): A fatal error has occurred. Check the logfile above for details

AttributeCreator_164_OUTPUT_-1_6456_Player (RecorderFactory): A fatal error has occurred. Check the logfile above for details

 

Thanks in advance 

FME 2021

 

Best answer by david_r

Thanks @mark2atsafe !

@soly Looks like a problem with the networkx package (and not FME), you’re not the only one reporting this error, see e.g. https://stackoverflow.com/questions/78288036/module-importlib-resources-has-no-attribute-files Unfortunately I have no knowledge of this package, perhaps you could try to contact the package author.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

david_r
Celebrity
  • August 14, 2024

When posting Python code, can you please format it using the “Code” block option:

Otherwise it’s very hard to read.


soly
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • August 14, 2024

@david_r 

i do not have it .


 


david_r
Celebrity
  • August 14, 2024

That’s strange…

@mark2atsafe Do you know what’s going on?


mark2atsafe
Safer
Forum|alt.badge.img+59
  • Safer
  • August 14, 2024

That’s strange…

@mark2atsafe Do you know what’s going on?

I don’t. I’ll look into that, but in the meantime I was able to edit the content to a code block by myself.


david_r
Celebrity
  • Best Answer
  • August 15, 2024

Thanks @mark2atsafe !

@soly Looks like a problem with the networkx package (and not FME), you’re not the only one reporting this error, see e.g. https://stackoverflow.com/questions/78288036/module-importlib-resources-has-no-attribute-files Unfortunately I have no knowledge of this package, perhaps you could try to contact the package author.


soly
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • August 16, 2024

@david_r  thanks .I will check it