How to import dolfinx into Jupyter notbook in VS Codes in windows 10 LTSC

I had installed VS codes and Docker Desktop in windows 10 2019 LTSC.
https://fenicsproject.org/download/
I followed the steps in the download page to pull dolfinx.
I can use dolfinx with Jupyter notebook in the browser but have been struggling with installing pyvista. The kernel in the browser will always crash when I try the example from the documentation.

https://docs.fenicsproject.org/dolfinx/main/python/_downloads/b94ac7be61dc3726ca331afd20f195d2/demo_poisson.py

  1. How can I customize dockerfile in VS Codes to use dolfinx? I have the image but cannot use it in the Jupyter.
  2. How can I install pyvista for the image of dolfinx?

See: Plot functions in dolfinx - #5 by dokken

You could use the image `dolfinx/lab’, which includes pyvista. See: dolfinx/Dockerfile at main · FEniCS/dolfinx · GitHub and the following lines for the exact commands used.

Thanks. Should I make any change for windows 10 system?
I am a newbie to this project.

As the docker container is using ubuntu, no changes should be needed except those highlighted already.

I repull the dolfinx image to create a container. I found that pyvista is not included in the docker image.
After I installed the pyvista package, I noticed this error when testing the introductory demo
demo:

No results were shown from the demo but a warning message:

WARNING:py.warnings:/usr/local/lib/python3.9/dist-packages/pyvista/plotting/plotting.py:115: UserWarning:
This system does not appear to be running an xserver.
PyVista will likely segfault when rendering.

Try starting a virtual frame buffer with xvfb, or using
pyvista.start_xvfb()

warnings.warn(

What is the variable pyvista.OF_SCREEN set to?
See for instance: dolfinx/demo_pyvista.py at 7b91f618ceb82b8ecbe4ea903f11e373c132efb0 · FEniCS/dolfinx · GitHub as to when you need to start a headless display.

I have Also covered the different plotting backends of pyvista in: Implementation — FEniCSx tutorial

dokken, Thanks for the reply.
I pull the latest image and created a new container in VS Code.

I copy the same code in the demo_pyvista.pydemo

I got this error:

WARNING:py.warnings:/usr/local/lib/python3.9/dist-packages/pyvista/plotting/plotting.py:115: UserWarning:
This system does not appear to be running an xserver.
PyVista will likely segfault when rendering.

Try starting a virtual frame buffer with xvfb, or using
pyvista.start_xvfb()

warnings.warn(

ERROR:root:bad X server connection. DISPLAY=
2022-04-25 19:09:12.644 ( 5.063s) [ 134DFC0]vtkXOpenGLRenderWindow.:464 ERR| vtkXOpenGLRenderWindow (0x4208c30): bad X server connection. DISPLAY=
Error: Canceled future for execute_request message before replies were done
at t.KernelShellFutureHandler.dispose (/root/.vscode-server/extensions/ms-toolsai.jupyter-2022.3.1000901801/out/extension.js:2:1204175)
at /root/.vscode-server/extensions/ms-toolsai.jupyter-2022.3.1000901801/out/extension.js:2:1223227
at Map.forEach ()
at v._clearKernelState (/root/.vscode-server/extensions/ms-toolsai.jupyter-2022.3.1000901801/out/extension.js:2:1223212)
at v.dispose (/root/.vscode-server/extensions/ms-toolsai.jupyter-2022.3.1000901801/out/extension.js:2:1216694)
at /root/.vscode-server/extensions/ms-toolsai.jupyter-2022.3.1000901801/out/extension.js:2:533674
at t.swallowExceptions (/root/.vscode-server/extensions/ms-toolsai.jupyter-2022.3.1000901801/out/extension.js:2:913059)
at dispose (/root/.vscode-server/extensions/ms-toolsai.jupyter-2022.3.1000901801/out/extension.js:2:533652)
at t.RawSession.dispose (/root/.vscode-server/extensions/ms-toolsai.jupyter-2022.3.1000901801/out/extension.js:2:537330)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

You didn’t answer my question; what is pyvista.OFF_SCREEN in your code?

What happens if you add:
pyvista.start_xvfb() prior to plotting?

I try the following codes:

import pyvista
pyvista.OFF_SCREEN

So it is “False”

Then it is strange that it needs a virtual framebuffer.
Could you try to set the backend of plotting to ipygany or pythreejs as described in my tutorial:
https://jorgensd.github.io/dolfinx-tutorial/chapter1/fundamentals_code.html#plotting-the-mesh-using-pyvista

I added pyvista.start_xvfb() before ploting.
The mesh is now showing.

This also worked.