# pyvistaqt 3d backend - plot not interactive

**URL:** <https://mne.discourse.group/t/pyvistaqt-3d-backend-plot-not-interactive/5375>\
**Category:** Support & Discussions\
**Tags:** visualization\
**Created:** [August 4, 2022, 10:55am UTC](https://mne.discourse.group/t/pyvistaqt-3d-backend-plot-not-interactive/5375 "2022-08-04T10:55:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aalt](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@aalt](https://mne.discourse.group/u/aalt)\
**Post date:** [August 4, 2022, 10:55am UTC](https://mne.discourse.group/t/pyvistaqt-3d-backend-plot-not-interactive/5375/1 "2022-08-04T10:55:08Z")

</div>

- MNE version: e.g. 1.1.0
- pyvista version: e.g. 0.36.1
- pyvistaqt version: e.g. 0.9.0
- operating system: e.g. macOS 10.15

Hello,

I encountered an issue while trying to plot source localization.  
Here is a snippet of the code I’m using.

```python
import os
import mne
from mne import read_source_estimate
from mne.datasets import sample
print( __doc__ )

# Paths to example data
sample_dir_raw = sample.data_path()
sample_dir = os.path.join(sample_dir_raw, 'MEG', 'sample')
subjects_dir = os.path.join(sample_dir_raw, 'subjects')
fname_stc = os.path.join(sample_dir, 'sample_audvis-meg')
stc = read_source_estimate(fname_stc, subject='sample')

# Define plotting parameters
surfer_kwargs = dict(
    hemi='lh', subjects_dir=subjects_dir,
    clim=dict(kind='value', lims=[8, 12, 15]), views='lateral',
    initial_time=0.09, time_unit='s', size=(800, 800),
    smoothing_steps=5)

# Plot surface
with mne.viz.use_3d_backend('pyvista'):
    brain=stc.plot(**surfer_kwargs, time_viewer=True)
brain.add_text(0.1, 0.9, 'SourceEstimate', 'title', font_size=16)

```

The pyvistaqt window does appear without any error, but I can’t interact with it, the Mac Spinning Wheel appearing.  
Do you have any idea?

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [August 4, 2022, 1:46pm UTC](https://mne.discourse.group/t/pyvistaqt-3d-backend-plot-not-interactive/5375/2 "2022-08-04T13:46:21Z")

</div>

Hello @aalt, and welcome to the forum!

How did you run the code you shared with us? From the terminal, from a Juypyter Notebook, from the VS Code interactive window, …?

Also, could you please share the output of

```python
import mne
mne.sys_info()

```

Thanks!

Richard

---

<div class="post-metadata">

**Author:** ![aalt](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@aalt](https://mne.discourse.group/u/aalt)\
**Post date:** [August 4, 2022, 1:52pm UTC](https://mne.discourse.group/t/pyvistaqt-3d-backend-plot-not-interactive/5375/3 "2022-08-04T13:52:23Z")

</div>

Dear @richard, thank you!  
I am using PyCharm environment.

mne.sys\_info() gives:

```python
Platform: macOS-10.15.7-x86_64-i386-64bit
Python: 3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0.29.30)]
Executable: /Users/anaelle/PycharmProjects/main/venv/bin/python
CPU: i386: 4 cores
Memory: Unavailable (requires "psutil" package)
mne: 1.1.0
numpy: 1.23.1 {}
scipy: 1.9.0
matplotlib: 3.5.2 {backend=MacOSX}
sklearn: 1.1.1
numba: Not found
nibabel: 4.0.1
nilearn: 0.9.1
dipy: Not found
cupy: Not found
pandas: 1.4.3
pyvista: 0.36.1 {OpenGL 4.1 NVIDIA-14.0.32 355.11.11.10.10.143 via NVIDIA GeForce GT 755M OpenGL Engine}
pyvistaqt: 0.9.0
ipyvtklink: Not found
vtk: 9.2.0.rc2
qtpy: 2.1.0 {PyQt5=5.15.2}
ipympl: Not found
pyqtgraph: Not found
pooch: v1.6.0
mne_bids: Not found
mne_nirs: Not found
mne_features: Not found
mne_qt_browser: Not found
mne_connectivity: 0.3
mne_icalabel: 0.2

```

Bests.

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [August 4, 2022, 1:56pm UTC](https://mne.discourse.group/t/pyvistaqt-3d-backend-plot-not-interactive/5375/4 "2022-08-04T13:56:39Z")

</div>

Thank you.

- Can you try to run the script from the command line, outside of PyCharm, to see if this changes anything?
- Getting MNE and all dependencies installed manually in a way that actually works well can be notoriously difficult. We therefore suggest you closely follow our [installation instructions](https://mne.tools/stable/install/manual_install.html#installing-mne-python-with-all-dependencies), which ask you to create a `conda` environment; or you could even try out our standalone installer if you want.

Best wishes,  
Richard

---

<div class="post-metadata">

**Author:** ![aalt](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@aalt](https://mne.discourse.group/u/aalt)\
**Post date:** [August 22, 2022, 2:42pm UTC](https://mne.discourse.group/t/pyvistaqt-3d-backend-plot-not-interactive/5375/5 "2022-08-22T14:42:43Z")

</div>

Dear @richard, running the script in the terminal directly in Python has worked perfectly.  
Also running it in the terminal through PyCharm works fine.  
Looks like only the Python Console from PyCharm gives rise to this issue.

Thank you !

---

<div class="post-metadata">

**Author:** ![aalt](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@aalt](https://mne.discourse.group/u/aalt)\
**Post date:** [August 23, 2022, 12:23pm UTC](https://mne.discourse.group/t/pyvistaqt-3d-backend-plot-not-interactive/5375/6 "2022-08-23T12:23:12Z")

</div>

So after testing a few things up, like changing backends in source files, using several functions for plotting and visualisation, it turned out adding `matplotlib.use('Qt5Agg')` solved the problem !  
While I thought it was using default Qt5Agg backend, apparently it was not and forcing it did the thing.

Bests.
