Skip to content

Mayavi not working interactively in spyder #17518

@max3-2

Description

@max3-2

Problem Description

There are some issues described which may relate but none that reproduces this behavior so I will give this a try. At least to check if its reproducible on other machines.
I have added more detail on a mayavi issue (enthought/mayavi#1127) but to sum it up:

  • Mayavi tree needs an event loop
  • In a python console, call mlab.show()
  • In a IPython console call %gui qt before creating plots

Failure to do the above in either environment leads to backend issues when interacting with the figure. The follwing two codes are working examples in both environments which are expected to work and should before proceeding:

Python

# This is the python console tester
from mayavi import mlab
mlab.test_flow()
mlab.show()

# Now the interpreter blocks and you can proceed to interact with mayavi and the model tree, e.g. add new modules there

iPython

# This is the !i!python console tester
from mayavi import mlab
%gui qt

mlab.test_flow()

# Now the interpreter is still active and you can proceed to interact with mayavi and the model tree, e.g. add new modules there or code in new modules. Both will work

What steps reproduce the problem?

Assuming the ipython version, the behavior should be the same in spyder as the example above. However this is not the case. Initially, after importing, spyder reports a message:

[1]: from mayavi import mlab
Changing backend to Qt for Mayavi
[2]: 

Then, using the ipython version above will show the error initially reported in the mayavi issue, e.g. the event loop will not handle mayavi inputs. Adding mlab.show() to combine both soultions, e.g.

from mayavi import mlab
%gui qt  # You can test with and without this line, wont change the issue

mlab.test_flow()
mlab.show()

will actually block the spyder console and the interactive mayavi works as in a default python console. However, after closing the mayavi figure, the console is blocked and needs a hard reset (this is obviously not the case when running the example in a default python console)

Running the example for iypthon in jupyter qtconsole works as expected.

This is reported for win10 and the versions below. I do not have this issue running macOS.

Versions

  • Spyder version: 5.2.2 None
  • Python version: 3.9.10 64-bit
  • Qt version: 5.12.10
  • PyQt5 version: 5.12.3
  • Operating System: Windows 10
  • Additional: vtk 9.1.0, mayavi 4.7.4

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions