enthought / mayavi

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

`mplot.show()` Freezes Python REPL #1146

Open jusevitch opened 2 years ago

jusevitch commented 2 years ago

Calling mplot.show() successfully plots a figure, but when I close the figure GUI the Python REPL hangs forever. Ctrl+C and Ctrl+D have no effect, and I'm forced to kill the terminal and restart the REPL.

Minimum working examples:

Simple Example

from mayavi import mlab
mlab.show() # REPL hangs forever

Longer example (Taken from the MayaVi website)

# Create the data.
from numpy import pi, sin, cos, mgrid
dphi, dtheta = pi/250.0, pi/250.0
[phi,theta] = mgrid[0:pi+dphi*1.5:dphi,0:2*pi+dtheta*1.5:dtheta]
m0 = 4; m1 = 3; m2 = 2; m3 = 3; m4 = 6; m5 = 2; m6 = 6; m7 = 4;
r = sin(m0*phi)**m1 + cos(m2*phi)**m3 + sin(m4*theta)**m5 + cos(m6*theta)**m7
x = r*sin(phi)*cos(theta)
y = r*cos(phi)
z = r*sin(phi)*sin(theta)

# View it.
from mayavi import mlab
s = mlab.mesh(x, y, z)
mlab.show() # Plot works, but after closing GUI window the REPL hangs forever

Environment Details

Conda environment.yml file:

(for Python v3.8--I can provide one for v3.9 if needed)

name: myenvironment
channels:
  - pytorch
  - defaults
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=4.5=1_gnu
  - blas=1.0=mkl
  - brotli=1.0.9=he6710b0_2
  - brotlipy=0.7.0=py38h27cfd23_1003
  - bzip2=1.0.8=h7b6447c_0
  - ca-certificates=2022.3.29=h06a4308_0
  - certifi=2021.10.8=py38h06a4308_2
  - cffi=1.15.0=py38hd667e15_1
  - charset-normalizer=2.0.4=pyhd3eb1b0_0
  - cryptography=36.0.0=py38h9ce1e76_0
  - cudatoolkit=11.3.1=h2bc3f7f_2
  - cycler=0.11.0=pyhd3eb1b0_0
  - dbus=1.13.18=hb2f20db_0
  - expat=2.4.4=h295c915_0
  - ffmpeg=4.3=hf484d3e_0
  - fontconfig=2.13.1=h6c09931_0
  - fonttools=4.25.0=pyhd3eb1b0_0
  - freetype=2.11.0=h70c0345_0
  - giflib=5.2.1=h7b6447c_0
  - glib=2.69.1=h4ff587b_1
  - gmp=6.2.1=h2531618_2
  - gnutls=3.6.15=he1e5248_0
  - gst-plugins-base=1.14.0=h8213a91_2
  - gstreamer=1.14.0=h28cd5cc_2
  - icu=58.2=he6710b0_3
  - idna=3.3=pyhd3eb1b0_0
  - intel-openmp=2021.4.0=h06a4308_3561
  - jpeg=9d=h7f8727e_0
  - kiwisolver=1.3.2=py38h295c915_0
  - lame=3.100=h7b6447c_0
  - lcms2=2.12=h3be6417_0
  - ld_impl_linux-64=2.35.1=h7274673_9
  - libffi=3.3=he6710b0_2
  - libgcc-ng=9.3.0=h5101ec6_17
  - libgfortran-ng=7.5.0=ha8ba4b0_17
  - libgfortran4=7.5.0=ha8ba4b0_17
  - libgomp=9.3.0=h5101ec6_17
  - libiconv=1.15=h63c8f33_5
  - libidn2=2.3.2=h7f8727e_0
  - libpng=1.6.37=hbc83047_0
  - libstdcxx-ng=9.3.0=hd4cf53a_17
  - libtasn1=4.16.0=h27cfd23_0
  - libtiff=4.2.0=h85742a9_0
  - libunistring=0.9.10=h27cfd23_0
  - libuuid=1.0.3=h7f8727e_2
  - libuv=1.40.0=h7b6447c_0
  - libwebp=1.2.2=h55f646e_0
  - libwebp-base=1.2.2=h7f8727e_0
  - libxcb=1.14=h7b6447c_0
  - libxml2=2.9.12=h03d6c58_0
  - lz4-c=1.9.3=h295c915_1
  - matplotlib=3.5.1=py38h06a4308_1
  - matplotlib-base=3.5.1=py38ha18d171_1
  - mkl=2021.4.0=h06a4308_640
  - mkl-service=2.4.0=py38h7f8727e_0
  - mkl_fft=1.3.1=py38hd3c417c_0
  - mkl_random=1.2.2=py38h51133e4_0
  - munkres=1.1.4=py_0
  - ncurses=6.3=h7f8727e_2
  - nettle=3.7.3=hbbd107a_1
  - numpy=1.21.2=py38h20f2e39_0
  - numpy-base=1.21.2=py38h79a1101_0
  - openh264=2.1.1=h4ff587b_0
  - openssl=1.1.1n=h7f8727e_0
  - packaging=21.3=pyhd3eb1b0_0
  - pcre=8.45=h295c915_0
  - pillow=9.0.1=py38h22f2fdc_0
  - pycparser=2.21=pyhd3eb1b0_0
  - pyopenssl=22.0.0=pyhd3eb1b0_0
  - pyparsing=3.0.4=pyhd3eb1b0_0
  - pyqt=5.9.2=py38h05f1152_4
  - pysocks=1.7.1=py38h06a4308_0
  - python=3.8.13=h12debd9_0
  - python-dateutil=2.8.2=pyhd3eb1b0_0
  - pytorch=1.11.0=py3.8_cuda11.3_cudnn8.2.0_0
  - pytorch-mutex=1.0=cuda
  - qt=5.9.7=h5867ecd_1
  - readline=8.1.2=h7f8727e_1
  - requests=2.27.1=pyhd3eb1b0_0
  - scipy=1.7.3=py38hc147768_0
  - setuptools=58.0.4=py38h06a4308_0
  - sip=4.19.13=py38h295c915_0
  - six=1.16.0=pyhd3eb1b0_1
  - sqlite=3.38.2=hc218d9a_0
  - tk=8.6.11=h1ccaba5_0
  - torchaudio=0.11.0=py38_cu113
  - torchvision=0.12.0=py38_cu113
  - tornado=6.1=py38h27cfd23_0
  - typing_extensions=4.1.1=pyh06a4308_0
  - urllib3=1.26.8=pyhd3eb1b0_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.2.5=h7b6447c_0
  - zlib=1.2.11=h7f8727e_4
  - zstd=1.4.9=haebb681_0
  - pip:
    - aiohttp==3.8.1
    - aiosignal==1.2.0
    - apptools==5.1.0
    - async-timeout==4.0.2
    - attrs==21.4.0
    - commonmark==0.9.1
    - configobj==5.0.6
    - envisage==6.0.1
    - frozenlist==1.3.0
    - importlib-resources==5.6.0
    - iniconfig==1.1.1
    - mayavi==4.7.4
    - multidict==6.0.2
    - pip==22.0.4
    - pipe==1.6.0
    - pluggy==1.0.0
    - py==1.11.0
    - pyface==7.4.1
    - pygments==2.11.2
    - pyqt5==5.15.6
    - pyqt5-qt5==5.15.2
    - pyqt5-sip==12.9.1
    - pytest==7.1.1
    - rich==12.0.1
    - tomli==2.0.1
    - torchdiffeq==0.2.2
    - traits==6.3.2
    - traitsui==7.3.1
    - vtk==9.1.0
    - wslink==1.5.0
    - yarl==1.7.2
    - zipp==3.7.0
prefix: [redacted]
prabhuramachandran commented 2 years ago

Use IPython with ipython --gui qt or %gui qt when using a REPL. Also I just setup a conda env on conda-forge with Python 3.10 with VTK also from conda-forge and am not able to reproduce your problem on an Ubuntu 20.04 system.