Issue with plotting in Python Scripting Node

Hello,
i wanted to create an image output in a python scripting node [Python 3 - Anaconda] for fast prototyping. This has always worked so far, but after an update to KNIME 3.6.0 this now fails.

Code:
import matplotlib.pyplot as plt
plt.figure()
plt.plot([1,2,3,4])
plt.ylabel(‘some numbers’)
plt.show()

Error:
Traceback (most recent call last):
File “C:\Program Files\KNIME\plugins\org.knime.python2_3.6.0.v201807061638\py\PythonKernelBase.py”, line 278, in execute
exec(source_code, self._exec_env, self._exec_env)
File “”, line 7, in
File “C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\pyplot.py”, line 253, in show
return _show(*args, **kw)
File “C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\backend_bases.py”, line 208, in show
cls.mainloop()
File “C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt5.py”, line 1118, in mainloop
signal.signal(signal.SIGINT, signal.SIG_DFL)
File “C:\ProgramData\Anaconda3\lib\signal.py”, line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread


Could you please support me.

Best Regars
André

Hi André,

We introduced threading for Python 3 in KNIME Python 3.6.0 to support some use cases that came with KNIME Deep Learning - Keras, which is built on top of your Python integration.
You could try to change to Python 2 via the node’s Options tab, if Python 2 is okay with you.
For Python 3, there is no workaround as far as I know, unfortunately.

Thanks for reporting that issue! And sorry for all the trouble. We’ll try to move script execution back to the main thread.

Marcel

Hi Marcel,
I switched the whole system and lecture to Python3 (and only Python 3). This is a nightmare and a lot of extra work. .Could you please give me an indication when its will be fixed an released?

Best Regards
André

We’ll target the next bug fix release, i.e., 3.6.2. I can’t give you a timeline, unfortunately, as we just released 3.6.1.
If the plot does not need to be interactive, you could also use the Python View node to output the plot as an image.
Otherwise, downgrading to KNIME 3.5.3 seems to be the only solution at the moment, I’m afraid. Please find a download link here.

I’ll keep you posted on our progress. Nightly builds that contain a respective fix will be available earlier, if those are an option for you.

Hi,
I upgraded to “Welcome to KNIME 3.6.2” but the bug is still present. Can you give me a hit, when it will be fixed?

BR
André

Hi André,

The fix for this is under active development but didn’t make it into 3.6.2 in time. We’ll try to get it released as soon as possible.

Marcel

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.