For the record, my student installed WSL2, installed pyvista (and scooby) via pip. It worked (displayed plots) without further configuration. I don’t know why it worked in our case but doesn’t work in others, sorry! dokken’s links will be useful.
One suggestion for debugging is to check basic matplotlib functionality. Does matplotlib give the same error? e.g.
python3 -c "import matplotlib.pyplot as plt; import numpy; x=numpy.linspace(0,10,100); plt.plot(x,x); plt.show()"
Does matplotlib display the simple plot?
In regards to the WSL2 environment, it installs Ubuntu. Always use the ubuntu packages where possible, and don’t use pip to install packages. e.g. install matplotlib via
apt-get install python3-matplotlib
I mention this in case the reason pyvista (or matplotlib) worked for us and not for you is if you used pip instead of apt to install matplotlib. You can check which matploblib you’re using via python3 -c "import matplotlib; print(matplotlib.__path__)"
The situation is more complicated then we’d like it to be since ubuntu does not have its own pyvista package available yet (a request to make it available was made in Debian Bug#1001105). pip installation is a workaround which carries the danger of installing python packages with incompatibile library versions. The risk can be reduced by using the --no-deps
option to only install the specified packages and not pull in other package dependencies.
pyvista requires numpy, imageio, pillow, appdirs and vtk, which are all available for ubuntu. It also requires scooby, which, like pyvista, is not yet available for ubuntu. Hence to get pyvista installed on an ubuntu/debian system (including the WSL2 environment), I recommend:
-
check that numpy, imageio, pillow, appdirs and vtk have not been installed by pip
– inspect the contents of~/.local/lib/python3*/site-packages/
– remove any unwanted packages (delete the directory, or usepip uninstall <package>
) -
check that they have been installed by apt
apt-get install python3-numpy python3-imageio python3-pil python3-appdirs python3-vtk9
(you could use python3-vtk7
instead of python3-vtk9
if vtk9 is giving problems)
- install pyvista with
pip install --user --no-deps scooby pyvista