enthought / mayavi

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

TypeErrror on Windows with test functions / model tree #1127

Open max3-2 opened 2 years ago

max3-2 commented 2 years ago

Hi,

I'm getting a fairly strange TypeError which I can't seem to resolve. Any help on this one?

To reproduce, I start from a fairly clean install and just pip install mayavi, which leads to the following version of (error) packages:

pyface                        7.3.0
PyQt5                         5.12.3
PyQt5-sip                     12.9.0
traits                        6.3.2
traitsui                      7.2.1

I then proceed to start a python interpreter, and then go for

from mayavi import mlab
mlab.test_flow()  # Choose any test function here, all work on this call

So far so good. However if I open the tree view and try to add an module to the dataset underlying the example plot the interpreter crashes with the error below - independent of the module I try to add and independent of the starting point, e.g. the chosen example.

Traceback (most recent call last):
  File "C:\Users\elm1rng\AppData\Local\Python\py-venv\bosch-def\lib\site-packages\pyface\ui\qt4\action\action_item.py", line 184, in _qt4_on_triggered
    self.controller.perform(action, action_event)
  File "C:\Users\elm1rng\AppData\Local\Python\py-venv\bosch-def\lib\site-packages\traitsui\qt4\tree_editor.py", line 1189, in perform
    self.ui.do_undoable(self._perform, action)
  File "C:\Users\elm1rng\AppData\Local\Python\py-venv\bosch-def\lib\site-packages\traitsui\ui.py", line 655, in do_undoable
    action(*args, **kw)
  File "C:\Users\elm1rng\AppData\Local\Python\py-venv\bosch-def\lib\site-packages\traitsui\qt4\tree_editor.py", line 1192, in _perform
    node, object, nid = self._data
TypeError: cannot unpack non-iterable NoneType object
max3-2 commented 2 years ago

Just an update: many things do not work all related to self._data is None in the last line of the traceback. Cut planes from scatters are also not getting any data... Seems to be introduced in 4.7.4

max3-2 commented 2 years ago

Also, I cant install old versions since there seems to be a bug introduced? Cloning this repo at 4.7.1 and installing from source:

      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\---\Desktop\mayavi-4.7.1\setup.py", line 411, in <module>
          setup(
        File "C:\Users\---\AppData\Local\Python\py-venv\----def\lib\site-packages\numpy\distutils\core.py", line 169, in setup
          return old_setup(**new_attr)
        File "C:\Users\---\AppData\Local\Python\py-venv\----def\lib\site-packages\setuptools\__init__.py", line 155, in setup
          return distutils.core.setup(**attrs)
        File "C:\Users\---\AppData\Local\Python\py-venv\----def\lib\site-packages\setuptools\_distutils\core.py", line 148, in setup
          return run_commands(dist)
        File "C:\Users\---\AppData\Local\Python\py-venv\----def\lib\site-packages\setuptools\_distutils\core.py", line 163, in run_commands
          dist.run_commands()
        File "C:\Users\---\AppData\Local\Python\py-venv\----def\lib\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
          self.run_command(cmd)
        File "C:\Users\---\AppData\Local\Python\py-venv\----def\lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
          cmd_obj.run()
        File "C:\Users\---\AppData\Local\Python\py-venv\----def\lib\site-packages\numpy\distutils\command\install.py", line 60, in run
          r = self.setuptools_run()
        File "C:\Users\---\AppData\Local\Python\py-venv\----def\lib\site-packages\numpy\distutils\command\install.py", line 34, in setuptools_run
          return distutils_install.run(self)
        File "C:\Users\---\AppData\Local\Python\py-venv\----def\lib\site-packages\setuptools\_distutils\command\install.py", line 662, in run
          self.run_command('build')
        File "C:\Users\---\AppData\Local\Python\py-venv\----def\lib\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "C:\Users\---\AppData\Local\Python\py-venv\----def\lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
          cmd_obj.run()
        File "C:\Users\---\Desktop\mayavi-4.7.1\setup.py", line 268, in run
          build_tvtk_classes_zip()
        File "C:\Users\---\Desktop\mayavi-4.7.1\setup.py", line 254, in build_tvtk_classes_zip
          gen_tvtk_classes_zip()
        File "C:\Users\---\Desktop\mayavi-4.7.1\tvtk\setup.py", line 99, in gen_tvtk_classes_zip
          gen.generate_code()
        File "C:\Users\---\Desktop\mayavi-4.7.1\tvtk\code_gen.py", line 131, in generate_code
          self._write_wrapper_class(node, tvtk_name)
        File "C:\Users\---\Desktop\mayavi-4.7.1\tvtk\code_gen.py", line 221, in _write_wrapper_class
          self.wrap_gen.generate_code(node, out)
        File "C:\Users\---\Desktop\mayavi-4.7.1\tvtk\wrapper_gen.py", line 250, in generate_code
          self._gen_methods(node, out)
        File "C:\Users\---\Desktop\mayavi-4.7.1\tvtk\wrapper_gen.py", line 367, in _gen_methods
          get_set, allow_update_failure = self._gen_get_set_methods(klass, out)
        File "C:\Users\---\Desktop\mayavi-4.7.1\tvtk\wrapper_gen.py", line 762, in _gen_get_set_methods
          if not meths[vtk_attr_name] and get_sig[0][1]:
      IndexError: list index out of range
prabhuramachandran commented 2 years ago

@max3-2 -- as regards your first error, is this because of the fact that you are running the mlab commands without starting the main QT UI interactor loop. Use IPython and there do %gui qt before you start making Mayavi windows. Otherwise run a script with the last line being mlab.show() and then see.

As regards installation what you are doing here is not clear. Are you installing an old version with the latest VTK? Newer VTK versions introduced changes that are incompatible with old Mayavi versions, Mayavi depends on VTK so it is highly unlikely an old Mayavi version will work with a new VTK version. If you want to do that, try with an older VTK version.

max3-2 commented 2 years ago

@prabhuramachandran Thanks for the quick reply. Regarding your answers:

Use of mlab.show() and %gui qt

This does indeed fix this issue for both cases. I wonder what changed since I was using mayavi for literally many years and never had to call those. I always was below vtk==9, which I cant (see other reply below) now since I am on py3.9. Another hint might be the point with spyder below.

spyder

In the spyder console, it wills till throw the error. Can you / someone reproduce? I just run the snippet below:

from mayavi import
%gui qt

# For the above, I also tried the way around - does not matter

mlab.test_flow()

It should be noted that on the import statement, the console shows Changing backend to Qt for Mayavi, which it only does when in spyder, even this is an ipython console. Starting ipython from shell and then using %gui qt does work well as stated above. Can you make something of this message - seems like a logging output?

Then try to interact with the tree and the error will occur. Using mlab.show() actually does make it work in the spyder (ipython) terminal, however the event loop wont stop, e.g. after closing the mayavi window the terminal is not freed from the command and needs a hard reset.

Especially the behavior in spyder is unknown to me, as I said that was a setup I used extensively in the past, also in an interactive mode.

Second error

Indeed this was a mix of versions and is produced when installing older versions of mayavi on newer vtk setups. I try to not roll back to older vtk since I am stuck to py3.9 now. But yeah, this is the incompatibility there.