The following code runs ok from the Python Script node Editor, if you previously click on Reset Workspace.
# Copy input to output
from py2neo import Graph, types
from pandas import DataFrame
graph = Graph(host="xxxxx", bolt=True, bolt_port=7687, user="xxx", password="xxx")
query = "match (h:HistClin)-[rt]-(t:ConceptoTrad)-[rc]-(c:Concepto) where toString(h.id) =~ '20180624114754.*' return h,rt,t,rc,c"
result = graph.run(query).data()
df = DataFrame(result)
#output_table = input_table.copy()
output_table = df.copy()
If you run it from the Analytics Platform, or run it without resetting workspace, you get:
ERROR PythonKernel LookupError: No serializer extension having the id or processing python type "py2neo.types.Node" could be found.
ERROR Python Script (1⇒1) 0:556:0:618 Execute failed: An exception occured while running the python kernel. See console and log for details.
I’ve added close() as suggested, but it did not work. Am I missing something?
Traceback (most recent call last):
File "/opt/knime/knime_3.5.3/plugins/org.knime.python2_3.5.0.v201712011355/py/PythonKernel.py", line 491, in execute
exec(source_code, self._exec_env, self._exec_env)
File "<string>", line 24, in <module>
NameError: name 'close' is not defined
I’m not familiar with the py2neo library. It may not be exactly the same. But, are you sure this error is not related to the other thread Python node failing: No serializer extension having the id or processing python type “int”? See the post by MarcelW.
Solved: the problem is that you need to convert “node type” to something that matches a KNIME dataframe constituent types, eg. split the node attributes into several columns of type String and Int.
This applies to any Graph library based in Python (including py2neo).