# Pyvista doesn't work in pycharm

**URL:** <https://fenicsproject.discourse.group/t/pyvista-doesnt-work-in-pycharm/13246>\
**Category:** General\
**Tags:** visualization\
**Created:** [January 8, 2024, 9:25am UTC](https://fenicsproject.discourse.group/t/pyvista-doesnt-work-in-pycharm/13246 "2024-01-08T09:25:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jipeng\_Cui](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@Jipeng\_Cui](https://fenicsproject.discourse.group/u/Jipeng_Cui)\
**Post date:** [January 8, 2024, 9:25am UTC](https://fenicsproject.discourse.group/t/pyvista-doesnt-work-in-pycharm/13246/1 "2024-01-08T09:25:14Z")

</div>

Hi,

I am a new user of fenicsx. When I tried the tutorial on solving the [Poisson equation](https://jsdokken.com/dolfinx-tutorial/chapter1/fundamentals_code.html#plotting-the-mesh-using-pyvista), I ran into a problem with the visualization part.

Actually, I am running the program in Pycharm. When I run to use Pyvista to show the results, the program starts to run but cannot stop for a long time. In these lines

```auto
if not pyvista.OFF_SCREEN:
    plotter.show()
else:
    figure = plotter.screenshot("fundamentals_mesh.png")

```

However, it works if I didn’t use the unstructured grid, such as

```auto
import pyvista as pyvista
pyvista.set_jupyter_backend("pythreejs")

points = [[0, 0, 0],
          [1, 0, 0],
          [0.5, 0.667, 0]]
mesh = pyvista.PolyData(points)
mesh.plot(show_bounds=True, cpos='xy',color='red', point_size=20)

```

I’d like to know why it didn’t work and how can I do for that.

Thanks!

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [January 8, 2024, 9:30am UTC](https://fenicsproject.discourse.group/t/pyvista-doesnt-work-in-pycharm/13246/2 "2024-01-08T09:30:19Z")

</div>

> [@Jipeng\_Cui](#):
>
> I am a new user of fenicsx. When I tried the tutorial on solving the [Poisson equation](https://jsdokken.com/dolfinx-tutorial/chapter1/fundamentals_code.html#plotting-the-mesh-using-pyvista), I ran into a problem with the visualization part.

Are you running the notebook in pycharm, or a pythonscript in pycharm?

For your second example, you are using `pythreejs`, which is no longer part of pyvista’s backend.  
Could you please specify what versions of pyvista you are using.

Thirdly, in the latter example, you have not added a “show” command, so it is unclear if you are using the same logic as in your first snippet.

---

<div class="post-metadata">

**Author:** ![Jipeng\_Cui](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@Jipeng\_Cui](https://fenicsproject.discourse.group/u/Jipeng_Cui)\
**Post date:** [January 8, 2024, 9:39am UTC](https://fenicsproject.discourse.group/t/pyvista-doesnt-work-in-pycharm/13246/3 "2024-01-08T09:39:36Z")

</div>

Thanks for your kind reply!

At first, I run the code in the pythonscrpit in pycharm.

Secondly, I’m sorry that I forget to tell you I have removed the pythreejs in the brackets. The second example works. And my pyvista version is 0.43.1 which is the latest version.

Finally, I run plotter.show() but it still doesn’t stopped and nothing appear.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [January 8, 2024, 9:46am UTC](https://fenicsproject.discourse.group/t/pyvista-doesnt-work-in-pycharm/13246/4 "2024-01-08T09:46:19Z")

</div>

How did you install DOLFINx on your system, through apt, conda, docker or something else?

Are you also saying that something like the code in: [Creating an Unstructured Grid — PyVista 0.43.1 documentation](https://docs.pyvista.org/version/stable/examples/00-load/create-unstructured-surface.html#creating-an-unstructured-grid)  
does not run?

Could you also check the output of `print(pyvista.OFF_SCREEN)`?

---

<div class="post-metadata">

**Author:** ![Jipeng\_Cui](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@Jipeng\_Cui](https://fenicsproject.discourse.group/u/Jipeng_Cui)\
**Post date:** [January 8, 2024, 10:24am UTC](https://fenicsproject.discourse.group/t/pyvista-doesnt-work-in-pycharm/13246/5 "2024-01-08T10:24:41Z")

</div>

I install by conda.

The code you posted can be ran.

And the output of `print(pyvista.OFF_SCREEN)` is false.

Thanks.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [January 8, 2024, 10:32am UTC](https://fenicsproject.discourse.group/t/pyvista-doesnt-work-in-pycharm/13246/6 "2024-01-08T10:32:29Z")

</div>

Try removing: `pyvista.start_xvfb()`  
as that is the only difference in the codes.

---

<div class="post-metadata">

**Author:** ![Jipeng\_Cui](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@Jipeng\_Cui](https://fenicsproject.discourse.group/u/Jipeng_Cui)\
**Post date:** [January 8, 2024, 10:34am UTC](https://fenicsproject.discourse.group/t/pyvista-doesnt-work-in-pycharm/13246/7 "2024-01-08T10:34:46Z")

</div>

It works!

Thank you very much!

Could you please tell me why this line `pyvista.start_xvfb()`affects the code running?

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [January 8, 2024, 10:39am UTC](https://fenicsproject.discourse.group/t/pyvista-doesnt-work-in-pycharm/13246/8 "2024-01-08T10:39:25Z")

</div>

XVFB is a way to run off-screen plots, and is required for running inside docker images and in some other cases(like building the tutorial webpage).  
See: [Trame Jupyter Backend for PyVista — PyVista 0.44.dev0 documentation](https://docs.pyvista.org/version/dev//user-guide/jupyter/trame.html#other-considerations)

---

<div class="post-metadata">

**Author:** ![Jipeng\_Cui](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@Jipeng\_Cui](https://fenicsproject.discourse.group/u/Jipeng_Cui)\
**Post date:** [January 8, 2024, 12:33pm UTC](https://fenicsproject.discourse.group/t/pyvista-doesnt-work-in-pycharm/13246/9 "2024-01-08T12:33:19Z")

</div>

Thanks for your answer! I’m trying to understand!
