Python VTK for visualization in a jupyter notebook running on docker

Hi - I’d like to use python vtk to visualize objects in a jupyter notebook. I am able to run the notebook locally on my machine and it works. However, I am unable to run it when the jupyter notebook is running in docker (ubuntu 16.04). Has anybody got this working ?

I’ve been successful with MyBinder! You’ll have to install libgl1-mesa-dev and xvfb to your docker then run a start script similar to the following to initialize the display when the session starts:

#!/bin/bash
export DISPLAY=:99.0
which Xvfb
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
sleep 3
exec "$@"

You can try to follow what I’ve done for this repository: https://github.com/OpenGeoVis/PVGeo-Examples

Note that I’m am currently working on that repo and its contents are subject to change

Update: I’ve created a cookie cutter to quickly make a MyBinder project: https://github.com/vtkiorg/cookiecutter-vtki-binder

And here is a sample project created using that template: Binder

1 Like

It looks like people are still using the examples I shared here - which have been updated:

Thank you for your help! The mybinder project that you sent on april 7th that uses vtki works well. however laters one you sent with pyvista has an issue. It seems to do 2d plots okay. However 3D visualization has an issues. For example, when I try running examples/00-load/create-point-cloud.ipynb, I just get a grey screen where the plot should be. Any idea what could be causing this?

Hey - I’m aware of that issue (seems to have occurred this week) and it has to do with a bug in one of PyVista’s dependencies.

I’m working to fix it!

Ok, great. Thank you!

Any luck with this?

Ah yes, we’ve managed to track down the issue but haven’t deployed a fix. adding auto_close=False to all .show() calls should allow the scene to show in the panel output