Dear all,
using the new Python Extension Development (Labs) documented here Pure Python Node Extensions Guide | KNIME Documentation and here Python Extension Development (Labs) — KNIME Python API documentation I’m currently trying to implement my own Python-based extension with nodes which should open separate GUIs for the user to interact with - from a simple custom input to complex data interaction.
Unluckily Knime AP freezes when trying to execute the Node. The window of the GUI opens, but only the outline of the window is shown in 95% of the cases (in the remaining 5% the content - which exists in my “real” code is displayed, but the GUI crashes nevertheless). Afterwards the Qt-Window freezes. In some cases, I can kill the window by clicking the “X”, in some cases I have to kill Knime AP.
The entry in the config.yml looks like:
org.my_org.my_extension:
debug_mode: false
python_executable: /absolute/path/to/my/python/executable/bin/python
src: /absolute/path/to/my/extension
I’ll skip the content of the knime.yml since I think this is irrelevant for now.
A minimal working example of the extension’s node code is:
"""PyQt/PySide Qt GUI test node."""
import logging
import sys
import knime.extension as knext # type: ignore[import-untyped]
from PyQt6.QtWidgets import QApplication, QWidget
# from PySide6.QtWidgets import QApplication, QWidget
LOGGER = logging.getLogger(__name__)
__all__: list[str] = ["MyGUITestNode"]
@knext.node(
name="GUI Test Node",
node_type=knext.NodeType.OTHER,
icon_path="../../icons/my_icon.png",
category="/", # defining something else doesn't work as well, btw...
)
class MyGUITestNode:
"""
Short one-line description of the node.
Long description of the node which is in fact short.
"""
def configure(
self,
configure_context: knext.ConfigurationContext, # noqa: ARG002
) -> None:
"""
Configure the Python node.
Parameters
----------
configure_context
_description_
"""
return
def execute(
self,
exec_context: knext.ExecutionContext,
) -> None:
"""
Execute node.
Parameters
----------
exec_context
_description_
"""
# PyQt6 and PySide6 - both equal:
app = QApplication(sys.argv)
window = QWidget()
# this freezes Knime AP:
window.show()
# We don't even get here:
app.exec()
As soon as the window is killed, the log/terminal shows the following stdout/stderr:
ERROR KNIME-Worker-0-MyGUITestNode 3:1 Node Execute failed: Error while sending a command.
py4j.Py4JException: Error while sending a command.
at py4j.CallbackClient.sendCommand(CallbackClient.java:397)
at py4j.CallbackClient.sendCommand(CallbackClient.java:356)
at py4j.reflection.PythonProxyHandler.invoke(PythonProxyHandler.java:106)
at jdk.proxy6/jdk.proxy6.$Proxy61.execute(Unknown Source)
at org.knime.python3.nodes.CloseablePythonNodeProxy.execute(CloseablePythonNodeProxy.java:570)
at org.knime.python3.nodes.DelegatingNodeModel.lambda$4(DelegatingNodeModel.java:233)
at org.knime.python3.nodes.DelegatingNodeModel.runWithProxy(DelegatingNodeModel.java:295)
at org.knime.python3.nodes.DelegatingNodeModel.execute(DelegatingNodeModel.java:231)
at org.knime.core.node.NodeModel.executeModel(NodeModel.java:605)
at org.knime.core.node.Node.invokeFullyNodeModelExecute(Node.java:1331)
at org.knime.core.node.Node.execute(Node.java:1038)
at org.knime.core.node.workflow.NativeNodeContainer.performExecuteNode(NativeNodeContainer.java:618)
at org.knime.core.node.exec.LocalNodeExecutionJob.mainExecute(LocalNodeExecutionJob.java:98)
at org.knime.core.node.workflow.NodeExecutionJob.internalRun(NodeExecutionJob.java:201)
at org.knime.core.node.workflow.NodeExecutionJob.run(NodeExecutionJob.java:120)
at org.knime.core.util.ThreadUtils$RunnableWithContextImpl.runWithContext(ThreadUtils.java:369)
at org.knime.core.util.ThreadUtils$RunnableWithContext.run(ThreadUtils.java:223)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at org.knime.core.util.ThreadPool$MyFuture.run(ThreadPool.java:143)
at org.knime.core.util.ThreadPool$Worker.run(ThreadPool.java:277)
Caused by: py4j.Py4JNetworkException: Error while sending a command: c
p0
execute
to10
ro11
eat py4j.ClientServerConnection.sendCommand(ClientServerConnection.java:253) at py4j.CallbackClient.sendCommand(CallbackClient.java:384) ... 20 moreCaused by: py4j.Py4JException: Received empty command
at py4j.ClientServerConnection.sendCommand(ClientServerConnection.java:236)
… 21 more
Instead opening a GUI from within Knime works like a charm when:
- Defining anything else in the configure()/execute() methods, also defining inputs/outputs works. –> Extension setup in config.yml, knime.yml and Python Venv should be defined correctly.
- setting
debug: truein the config.yml. Unluckily this is not applicable for a “production quality” extension. - executing a Python script containing the code using a Python subprocess call from within the node’s
execute()method, see blow for a code snippet. This is not applicable due not allowing for communication with the GUI (except for using pipes, which is far from desired). - Using a Python Script Node with the code from
execute()instead. This is not applicable for obvious reasons.
I’m using Knime AP 5.8.1 LTS with Python 3.13.7 - but also tried this on Knima AP 5.4 and Python versions 3.10, 3.11 and 3.12 - all combinations result in the same problem. The packages installed in my Python venv are listed at the end of this post.
I’m on Linux with SUSE Linux Enterprise Server 15.
Can you reproduce the error with your setup or do you have an idea how to resolve this?
Many thanks in advance and best regards,
Johannes