enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.31k stars 285 forks source link

freshly installed mayavi is freezing in about 95% of cases when trying to import mlab #1062

Closed Kukuster closed 2 years ago

Kukuster commented 3 years ago

Almost every time I try to execute from mayavi import mlab, it freezes. Either in jupyter, in mayavi2 graphical program, or with plain python in CLI. Out of about 80 times, I've got it to work only 4-5 times.

Dep version
Ubuntu 20.04.2 LTS
Python 3.8.10
Mayavi 4.7.3
vtk 9.0.3
pyqt5 5.15.4
libvtk6-dev 6.3.0+dfsg2-5build2
libpq5 12.7-0ubuntu0.20.04.1

I've been trying to reinstall several dependencies, like pyqt5, libvtk6-dev, libpq5

I've been installing mayavi through pip. By the way, a few times "Building wheel" was freezing when trying to install mayavi. When this occurred, I had to terminate all pip processes, reinstall PyQt5, then install --upgrade half-installed mayavi installation.

In all cases when I've got it to import successfully it was in jupyter. Here's the farthest I was able to get:

Screenshot from 2021-07-29 21-18-48_cut source:

%gui qt
import numpy as np
from mayavi import mlab
mlab.init_notebook()
def test_surf():
    """Test surf on regularly spaced co-ordinates like MayaVi."""
    def f(x, y):
        sin, cos = np.sin, np.cos
        return sin(x + y) + sin(2 * x - y) + cos(3 * x + 4 * y)

    x, y = np.mgrid[-7.:7.05:0.1, -5.:5.05:0.05]
    s = mlab.surf(x, y, f)
    #cs = mlab.contour_surf(x, y, f, contour_z=0)
    return s
test_surf()

All 2 or 3 times it outputted exactly the same stuff: Image(value=b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x01\x90\x00\x00\x01^\x08\x02\x00\x00\x00$?\xde_\x00\… And that's it. It didn't render anything

--- Upd --- To clarify, I need:

  1. To fix this weirdest thing, freezing when trying to import mlab in vast majority of cases. I absolutely need to figure this out. It's not just freezing my python, it's freezing my job.
  2. To figure out how to get an actual picture from mayavi. Ideally with interactive features, and the ability to export a picture file. I'd imagine this won't be hard when I resolve the freezing problem.

Thanks a lot!

Kukuster commented 3 years ago

Several days ago I managed to import mlab in mayavi2 and I have left this session open since then. The garbage collector works well for me, it doesn't build up a lot of RAM. The visual works well, all good, getting an actual picture is no big deal.

The freezing issue remains.

Mayavi2 is still my go-to option for 3d right now, so if it happens that you'll want to use my help to diagnose this issue, I'll be there. It'll take about an hour to go through the painful process of importing it, but I will be doing this anyway.

nchampag commented 3 years ago

Try downgrading to VTK 9.0.1.

johnwlambert commented 3 years ago

I'm seeing the same issue as @Kukuster saw originally.

prabhuramachandran commented 3 years ago

Sorry about that. The issue is fixed in master and we will push a release sometime later this week to address this. If you want you can test it out using::

pip uninstall mayavi
pip install https://github.com/enthought/mayavi/zipball/master 
rahulporuri commented 2 years ago

closing as the latest 4.7.4 mayavi release fixes this issue. please try reinstalling mayavi.