Python views issues (Portal, colors and legend)

python
#1

Hi

I have a few challenges with my python view note.

It was recommended to me and really worked well for that problem (Double y-axis). So thank you community :slight_smile:

I have encountered additional challenges since then.

First, I get an error message, when I try to run my workflow on the portal. It runs fine in desktop KNIME.
It says “No display name”. The full length of the error can be read in the end of this post.

Second, I can’t figure out how to make dynamic colors and include legends to the python view. Right now I can only make each input type one color (atm. red and blue - with no legends)
I have unsuccessfully followed these guides:

https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.legend.html

I have attached shots of my workflow (so what comes after my python view, that is inside the line plot component) and the script in my python view.

Hope some of the more experienced members of this community can help.
If I have supplied too few information’s, please let med know. Then I’ll try to supply the correct ones.

Best regard
Bjarke

Full length error:
Execute failed: no display name and no $DISPLAY environment variable Traceback (most recent call last): File "<string>", line 9, in <module> File "/usr/lib/python3/dist-packages/pandas/plotting/_core.py", line 2677, in call sort_columns=sort_columns, **kwds) File "/usr/lib/python3/dist-packages/pandas/plotting/_core.py", line 1902, in plot_frame **kwds) File "/usr/lib/python3/dist-packages/pandas/plotting/_core.py", line 1729, in _plot plot_obj.generate() File "/usr/lib/python3/dist-packages/pandas/plotting/_core.py", line 251, in generate self._setup_subplots() File "/usr/lib/python3/dist-packages/pandas/plotting/_core.py", line 302, in _setup_subplots fig = self.plt.figure(figsize=self.figsize) File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 539, in figure **kwargs) File "/usr/lib/python3/dist-packages/matplotlib/backend_bases.py", line 171, in new_figure_manager return cls.new_figure_manager_given_figure(num, fig) File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 1049, in new_figure_manager_given_figure window = Tk.Tk(className="matplotlib") File "/usr/lib/python3.6/tkinter/init.py", line 2023, in init self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) _tkinter.TclError: no display name and no $DISPLAY environment variable

1 Like

#2

It would be helpful if you could provide us with a ‘working’ (or not working that is) example where the error shows up. Then we could try to solve the problem an tur your exampel into a working one - then you could adapt it.

With screenshots and parts of Logs it is not so eays to judge what is going on.

0 Likes

#3

Hi mlauber71

Thank you for reaching out.

I’m a bit constrained by my company’s NDA.

My workflow is looking into our database, and if I replace the data import with some generic data the entire workflow fucks up. I just tried - and failed.

It will be difficult for me to show you the real problem without violating my loyalty to my company.
Is there any other way I can provide the needed information’s?

Again, thank you very much for helping. Much appreciated.

Best regards
Bjarke

0 Likes

#4

Hi again

I can tell, that the web portal runs on a Linux server.
And I think, the error might have something to do, with the python view node trying to display the image on the server for interactivity, instead of just transferring to report and table, as I usually do. The server doesn’t have a program for displaying images.

Best regards
Bjarke

0 Likes

#5

Of course I understand that you cannot send confidential informations. So it would make sense to try it with a generic/public data set. In this way we could be sure it is a general problem and not related to your specific data.

The tricky part with KNIME and Python is to get the results out to reuse them. Once the graphic is back in KNIME it should be possible to use the standard nodes.

Linux might add another aspect to the provlem. My experience is focussed on Windows and McOS.

0 Likes

#6

Hi mlauber71

I’ll look into your solutions. Thank you for providing those.

Yes, it is troublesome with the confidentiality. If this all fails I will have to re write a workflow, that shows my problem. Though I hope it can be solved easier.

If anybody else have some suggestions, they will still be very much appreciated.

Best regards
Bjarke

0 Likes

#7

Hi there @BjarkePetersen,

if you are talking about Portal as WebPortal that comes with KNIME Server product change Category into KNIME Server to get more attention.

Br,
Ivan

0 Likes

#8

Hi ipazin

I do mean WebPortal.

But the other problems (color + legends) is still there.
Those this problem is a bit more fundamental.

I will change the category.

Best
Bjarke

0 Likes

#9

Hi

Thus far I am not permitted to change the category into server.
And now the edit function seems to have disappeared, when I try to change it into something else.

I guess it must be very visible by now, that I am a beginner in this game :slight_smile:

Best
Bjarke

0 Likes

#10

Hi @BjarkePetersen,

if I got you right you said it works in KNIME Desktop and not on Portal so I would say it is KNIME Server category. Additional things like color and legend that are general if won’t get covered by this topic you can open a new one.

I have changed category.

Br,
Ivan

1 Like

#11

Just to make sure. Can you try a simple example on the server? And make sure you have the necessary extensions installed.

Then we would get an idea if it is a general problem with python or specific for your packages and code.

https://www.knime.com/book/python-extensions

0 Likes

#12

By default the executor on the server is running headless, i.e. without any UI interaction. This message

indicates that your Python code requires UI access. It’s usually sufficient to provide a virtual X server to such processes via Xvfb and set the DISPLAY environment variable accordingly.

3 Likes

#13

Hi Thor

Thank you for your involvement.
It helped me in the right direction.

I found this page, that solves the problem:

I simply added these lines before importing matplotlib.pyplot:
“import matplotlib as mpl
mpl.use(‘Agg’)”

I now have another issue about maximum length of cell contents. But that’s a different story.

So again, thank you very much for giving a push in the right direction :slight_smile:

Best regards
Bjarke

4 Likes

closed #14

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

0 Likes