Off screen plotter not working, even with off_screen=True
See original GitHub issueDescribe the bug, what’s wrong, and what you expected.
Hi guys, I’m trying to render with an off_screen plotter, but still getting:
AttributeError:
This plotter has not yet been set up and rendered with ``show()``.
Consider setting ``off_screen=True`` for off screen rendering.
I already created the plotter as:
plotter = pv.Plotter(off_screen=True)
but I’m still getting the same error.
I also previously run:
sudo apt-get install xvfb
export DISPLAY=:99.0
export PYVISTA_OFF_SCREEN=true
export PYVISTA_USE_IPYVTK=true
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
sleep 3
I’m also setting these environment variables just before the pyvista import in my Python code:
import os
os.environ['PYVISTA_OFF_SCREEN'] = 'true'
os.environ['PYVISTA_USE_IPYVTK'] = 'true'
os.environ['PYVISTA_USE_PANEL'] = 'true'
import pyvista as pv
Note: I don’t have python-qt4
installed since python-qt4
package is not available over Ubuntu 22.04.
Steps to reproduce the bug.
Next is the code that reproduces the error. This code was working on pyvista 0.26
over Ubuntu 16.04, Python 3.5. I just upgraded to Ubuntu 22.04 with pyvista 0.34.2
, Python 3.10.
plotter = pv.Plotter(off_screen=True)
plotter.add_mesh(mesh, texture=texture, lighting=False)
# Get render:
render_as_array = plotter.image.copy() # This is the line that throws the error.
System Information
--------------------------------------------------------------------------------
Date: Thu Jun 30 17:20:03 2022 -03
OS : Linux
CPU(s) : 8
Machine : x86_64
Architecture : 64bit
RAM : 15.5 GiB
Environment : Jupyter
File system : ext4
GPU Vendor : Mesa/X.org
GPU Renderer : llvmpipe (LLVM 13.0.1, 256 bits)
GPU Version : 4.5 (Core Profile) Mesa 22.0.1
Python 3.10.4 (main, Apr 2 2022, 09:04:19) [GCC 11.2.0]
pyvista : 0.34.2
vtk : 9.2.0
numpy : 1.22.4
imageio : 2.19.3
appdirs : 1.4.4
scooby : 0.5.12
matplotlib : 3.5.2
IPython : 8.4.0
ipyvtklink : 0.2.2
scipy : 1.8.1
tqdm : 4.64.0
meshio : 5.3.4
--------------------------------------------------------------------------------
Screenshots
No response
Code of Conduct
- I agree to follow this project’s Code of Conduct
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
vedo.plotter API documentation
This module defines the main class Plotter to manage actors and 3D rendering …
Read more >Don't show the figure from stc.plot() - Support & Discussions - MNE ...
I want to visualize the response of certain brain areas to stimuli, so I used the stc.plot() method to plot the brain image....
Read more >Window displays off screen when 2nd monitor is no longer ...
The problem is that the pop up window still shows up on the 2nd screen even if there isn't a monitor attached. I...
Read more >show — PyVista 0.37.0 documentation
Jupyter notebook plotting backend to use. One of the following: 'none' : Do not display in the notebook. 'pythreejs ...
Read more >Tips and Tricks — mayavi 4.8.1 documentation
The PNG backend relies on offscreen rendering working correctly on your platform. ... from mayavi import mlab mlab.options.offscreen = True ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ideally image would work, or if it doesn’t, it returns an intelligible error.
We might just consider using screenshot and discouraging image, or at the very least providing better documentation.
It works!
Are there any differences in calling
screenshot()
overimage
? (for example, in execution times).Is this supposed to be a feature (not calling
image
anymore)? So I know if I need to correct the code from some version number.