enthought / mayavi

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

terminates when calling mlab.show() #1205

Open LorenzSLH opened 1 year ago

LorenzSLH commented 1 year ago

System: Ubunutu 20.04 for Windows Python: 3.8

Using a virtual enviroment with following packages:

Package                Version  Editable project location
---------------------- -------- -------------------------------------
aiohttp                3.8.3
aiosignal              1.2.0
apptools               5.2.0
async-timeout          4.0.2
attrs                  22.1.0
autopep8               1.6.0
celluloid              0.2.0
charset-normalizer     2.1.1
configobj              5.0.6
contourpy              1.0.6
CoolProp               6.4.1
cycler                 0.11.0
envisage               6.1.0
ffmpeg-python          0.2.0
fonttools              4.38.0
frozenlist             1.3.1
future                 0.18.2
idna                   3.4
importlib-resources    5.10.0
kiwisolver             1.4.2
llvmlite               0.38.0
matplotlib             3.6.2
matplotlib-label-lines 0.4.1
mayavi                 4.8.1
multidict              6.0.2
numba                  0.55.1
numpy                  1.21.2
packaging              21.3
pandas                 1.5.1
Pillow                 9.1.0
pip                    23.0
pkg_resources          0.0.0
pycodestyle            2.8.0
pyface                 7.4.2
PyFoam                 2022.9
Pygments               2.13.0
pyparsing              3.0.8
PyQt5                  5.15.8
PyQt5-Qt5              5.15.2
PyQt5-sip              12.11.1
PySide2                5.15.2.1
PySide6                6.2.4
python-dateutil        2.8.2
pytz                   2022.6
scipy                  1.7.1
setuptools             44.0.0
shiboken2              5.15.2.1
shiboken6              6.2.4
sigfig                 1.3.1
six                    1.16.0
sortedcontainers       2.4.0
toml                   0.10.2
traits                 6.3.2
traitsui               7.4.1
triangle               20220202
vtk                    9.2.2
wslink                 1.9.1
yarl                   1.8.1
zipp                   3.10.0

Issue:

When calling the example it terminates without any errors at the code line: mlab.show(). I run the example in the debugger of Visual Studio Code.

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()

When running the command 'mayavi2' in the python console, it opens up an engine but as soon as a close it i get the following error returned:

QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-lorenz'
Traceback (most recent call last):
  File "/home/lorenz/Python/Turbo/turboVenv/lib/python3.8/site-packages/pyface/ui/qt4/gui.py", line 177, in event
    self._callable(*self._args, **self._kw)
  File "/home/lorenz/Python/Turbo/turboVenv/lib/python3.8/site-packages/envisage/application.py", line 320, in stop
    self.plugin_manager.stop()
  File "/home/lorenz/Python/Turbo/turboVenv/lib/python3.8/site-packages/envisage/plugin_manager.py", line 157, in stop
    self.stop_plugin(plugin)
  File "/home/lorenz/Python/Turbo/turboVenv/lib/python3.8/site-packages/envisage/plugin_manager.py", line 165, in stop_plugin
    plugin.activator.stop_plugin(plugin)
  File "/home/lorenz/Python/Turbo/turboVenv/lib/python3.8/site-packages/envisage/plugin_activator.py", line 45, in stop_plugin    plugin.stop()
  File "/home/lorenz/Python/Turbo/turboVenv/lib/python3.8/site-packages/apptools/logger/plugin/logger_plugin.py", line 98, in stop
    service.save_preferences()
  File "/home/lorenz/Python/Turbo/turboVenv/lib/python3.8/site-packages/apptools/logger/plugin/logger_service.py", line 53, in save_preferences
    self.preferences.preferences.save()
  File "/home/lorenz/Python/Turbo/turboVenv/lib/python3.8/site-packages/apptools/preferences/scoped_preferences.py", line 336, in save
    self._get_primary_scope().save(file_or_filename)
  File "/home/lorenz/Python/Turbo/turboVenv/lib/python3.8/site-packages/apptools/preferences/preferences.py", line 396, in save
    config_obj.write()
  File "/home/lorenz/Python/Turbo/turboVenv/lib/python3.8/site-packages/configobj.py", line 2128, in write
    with open(self.filename, 'wb') as h:
FileNotFoundError: [Errno 2] No such file or directory: '/home/lorenz/.enthought/mayavi_e3/preferences.ini'

Looking forward to your replies and ideas how to solve the issue. My goal is to use mayavi as my 3D plotting library to visualise parametric surfaces, meshes and curves.

With best regards, Lorenz

prabhuramachandran commented 1 year ago

This is a bit strange, could you create this directory: /home/lorenz/.enthought/mayavi_e3/ and try again? mayavi2 really needs an overhaul and will likely have various issues. Using Mayavi via mlab in scripts or an ipython session should be smoother.