vcs icon indicating copy to clipboard operation
vcs copied to clipboard

When running plot() function in a Jupyter Notebook, a greyed out window appears.

Open downiec opened this issue 7 years ago • 18 comments

If vcs.init() is run in a Jupyter notebook, it should automatically detect and have bg=true to avoid the greyed out window when sidecar is used in a Jupyter Notebook.

downiec avatar Jan 28 '19 22:01 downiec

Do we need to detect that we're running in a Jupyter notebook somehow, or can the default just be bg=True?

scottwittenburg avatar Jan 28 '19 23:01 scottwittenburg

no default needs to be bg=False as now. Look for the bit of code I added to detect notebook, for sidecar

doutriaux1 avatar Jan 28 '19 23:01 doutriaux1

Actually the code should already be in place (I thought I did code this): https://github.com/CDAT/vcs/blob/master/vcs/Canvas.py#L931-L935

I wo der why it's not picking it up

doutriaux1 avatar Jan 28 '19 23:01 doutriaux1

@scottwittenburg is it related to the new vtk-cdat ?

doutriaux1 avatar Jan 28 '19 23:01 doutriaux1

I remember seeing a window even with mesalib, maybe it's a similar issue?

doutriaux1 avatar Jan 28 '19 23:01 doutriaux1

I think I'll need some instructions on how to reproduce this if I'm to be of any help.

scottwittenburg avatar Jan 28 '19 23:01 scottwittenburg

according to @downiec when in a jupyternotebook with the non-mesa env (py3) x=vcs.init();x.plot([1,2,3]) make a window appear

doutriaux1 avatar Jan 28 '19 23:01 doutriaux1

we do not want the window appear, hence bg=True

doutriaux1 avatar Jan 28 '19 23:01 doutriaux1

Could it be because my conda environment? I just remembered I'm using the old conda environment because that's the one that's currently working. I'll let you know

downiec avatar Jan 28 '19 23:01 downiec

Sounds good, thanks @downiec.

scottwittenburg avatar Jan 29 '19 00:01 scottwittenburg

What vcs version do I need? I tried pulling from master and then running python setup.py install, but now I'm getting an error and it won't plot anything. AttributeError: module 'vtkmodules.all' has no attribute 'vtkRenderingOpenGLPython'

I emailed a screenshot.

downiec avatar Jan 29 '19 00:01 downiec

I noticed if I run this command: canvas.plot(clt,"default","default",bg=True) Where I set bg=True, then it works correctly without the error.

downiec avatar Jan 29 '19 00:01 downiec

Strange... if I run the command, initially it will have the error, but if I keep running a few times (without changing the code or parameters), eventually it works correctly. Is it because something needs to be loaded in the back end?

downiec avatar Jan 29 '19 00:01 downiec

One last comment. In the JupyterLab Notebook, first time I run the cell, I get: AttributeError: module 'vtkmodules.all' has no attribute 'vtkRenderingOpenGLPython' Second time I run the cell (same exact code, I just run the cell again): ZeroDivisionError: float division by zero Third time I run it, it plots without an error.

downiec avatar Jan 29 '19 00:01 downiec

Sorry @downiec, I saw your email about this before I got here, so I responded there. Basically, the AttributeError: module 'vtkmodules.all' has no attribute 'vtkRenderingOpenGLPython' is the one that matters. Based on the stacktrace in your email, it's clear that's an old version of VTKPlots.py (from before we merged the Context2D work). Since you said you checked out vcs master and installed it using python setup.py install, I wonder if you're hitting something I encounter from time to time now that vcs is egg based. Have a look and see if there are multiple vcs egg files in your environment. They would be located somewhere like:

${CONDA_HOME}/envs/${JUPYTER_VCDAT_ENV}/lib/python3.6/site-packages/

If you have more than one for vcs, you can move them out of the way (or just delete them all), and then run python setup.py install again from the vcs repository directory.

scottwittenburg avatar Jan 29 '19 03:01 scottwittenburg

@scottwittenburg Thanks for the response, I went ahead and removed the vcs egg files like you said, and then I ran python setup.py install. That all fixed the error, thanks! Unfortunately it doesn't resolve the greyed out window issue. Basically, if I run the following in a Jupyter Lab Notebook: canvas.plot(clt,"default","default") The plot is made, no problem. But then there's also a separate greyed out window that pops up and it can't be closed or minimized etc, it's just there. I tried running: canvas.plot(clt,"default","default",bg=True) And the issue still persists, with a greyed out window popping up. The window only goes away when I restart the kernel.

downiec avatar Jan 29 '19 19:01 downiec

@downiec Can you run the following in the same environment you just cleaned up, and see if the window pops up?

import vcs
canvas = vcs.init(bg=1)
canvas.plot([1, 2, 3, 4, 5])
canvas.png("simple.png")

Let me know what happens, thanks.

scottwittenburg avatar Jan 29 '19 19:01 scottwittenburg

I didn't see anything get plotted, but the grey window pops whether I run the code in a JupyterLab notebook, or I run it from Python in the console. Also a png named 'simple.png' was created.

Also another thing I notice is the grey window usually pops up after the data has been plotted. Sometimes almost a full second after the graph has already been plotted in the sidecar.

downiec avatar Jan 29 '19 19:01 downiec