conda-forge / mayavi-feedstock

A conda-smithy repository for mayavi.
BSD 3-Clause "New" or "Revised" License
4 stars 18 forks source link

Seg fault on mayavi example #16

Closed moorepants closed 2 years ago

moorepants commented 7 years ago

See:

moorepants@garuda:~$ ipython
Python 3.5.4 | packaged by conda-forge | (default, Aug 10 2017, 01:38:41) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: %paste
# Author: Gael Varoquaux <gael.varoquaux@normalesup.org>
# Copyright (c) 2008, Enthought, Inc.
# License: BSD Style.

from numpy import arange, pi, cos, sin

from traits.api import HasTraits, Range, Instance, \
        on_trait_change
from traitsui.api import View, Item, Group

from mayavi.core.api import PipelineBase
from mayavi.core.ui.api import MayaviScene, SceneEditor, \
                MlabSceneModel

dphi = pi/1000.
phi = arange(0.0, 2*pi + 0.5*dphi, dphi, 'd')

def curve(n_mer, n_long):
    mu = phi*n_mer
    x = cos(mu) * (1 + cos(n_long * mu/n_mer)*0.5)
    y = sin(mu) * (1 + cos(n_long * mu/n_mer)*0.5)
    z = 0.5 * sin(n_long*mu/n_mer)
    t = sin(mu)
    return x, y, z, t

class MyModel(HasTraits):
    n_meridional    = Range(0, 30, 6, )#mode='spinner')
    n_longitudinal  = Range(0, 30, 11, )#mode='spinner')

    scene = Instance(MlabSceneModel, ())

    plot = Instance(PipelineBase)

    # When the scene is activated, or when the parameters are changed, we
    # update the plot.
    @on_trait_change('n_meridional,n_longitudinal,scene.activated')
    def update_plot(self):
        x, y, z, t = curve(self.n_meridional, self.n_longitudinal)
        if self.plot is None:
            self.plot = self.scene.mlab.plot3d(x, y, z, t,
                                tube_radius=0.025, colormap='Spectral')
        else:
            self.plot.mlab_source.set(x=x, y=y, z=z, scalars=t)

    # The layout of the dialog created
    view = View(Item('scene', editor=SceneEditor(scene_class=MayaviScene),
                     height=250, width=300, show_label=False),
                Group(
                        '_', 'n_meridional', 'n_longitudinal',
                     ),
                resizable=True,
                )

my_model = MyModel()
my_model.configure_traits()

## -- End pasted text --
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
ERROR: In ../Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx, line 628
vtkXOpenGLRenderWindow (0x492f260): GLEW could not be initialized.

Segmentation fault (core dumped)
moorepants@garuda:~$ conda list mayavi
# packages in environment at /home/moorepants/miniconda3:
#
mayavi                    4.5.0               np112py35_2    conda-forge
moorepants@garuda:~$ conda list vtk
# packages in environment at /home/moorepants/miniconda3:
#
vtk                       7.1.1                  py35_202    conda-forge
moorepants@garuda:~$ conda list pyqt
# packages in environment at /home/moorepants/miniconda3:
#
pyqt                      4.11.4                   py35_2    conda-forge
moorepants@garuda:~$ conda list pyface
# packages in environment at /home/moorepants/miniconda3:
#
pyface                    5.1.0                    py35_1    conda-forge
moorepants commented 7 years ago

After creating this environment and letting mayavi use the default toolkit, the script works:

conda create -n mayavi python=3.6 "pyqt<5" "wxpython<4" mayavi ipython

But if I use the wx backend I get this error:

/home/moorepants/miniconda3/envs/mayavi/lib/python3.6/site-packages/pyface/wx/drag_and_drop.py:60: wxPyDeprecationWarning: Call to deprecated item. Use wx.DataFormat instead.
  PythonObject = wx.CustomDataFormat('PythonObject')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-5968ab238904> in <module>()
      7 
      8 from traits.api import HasTraits, Range, Instance,         on_trait_change
----> 9 from traitsui.api import View, Item, Group
     10 
     11 from mayavi.core.api import PipelineBase

~/miniconda3/envs/mayavi/lib/python3.6/site-packages/traitsui/api.py in <module>()
     34 
     35 try:
---> 36     from .editors.api import ArrayEditor
     37 except ImportError:
     38     # ArrayEditor depends on numpy, so ignore if numpy is not present.

~/miniconda3/envs/mayavi/lib/python3.6/site-packages/traitsui/editors/__init__.py in <module>()
     21 
     22 try:
---> 23     from .api import ArrayEditor
     24 except ImportError:
     25     pass

~/miniconda3/envs/mayavi/lib/python3.6/site-packages/traitsui/editors/api.py in <module>()
     22 from .button_editor import ButtonEditor
     23 from .check_list_editor import CheckListEditor
---> 24 from .code_editor import CodeEditor
     25 from .color_editor import ColorEditor
     26 from .compound_editor import CompoundEditor

~/miniconda3/envs/mayavi/lib/python3.6/site-packages/traitsui/editors/code_editor.py in <module>()
     34 #-------------------------------------------------------------------------------
     35 
---> 36 class ToolkitEditorFactory ( EditorFactory ):
     37     """ Editor factory for code editors.
     38     """

~/miniconda3/envs/mayavi/lib/python3.6/site-packages/traitsui/editors/code_editor.py in ToolkitEditorFactory()
     46 
     47     # Background color for marking lines
---> 48     mark_color = Color( 0xECE9D8 )
     49 
     50     # Object trait containing the currently selected line (optional)

~/miniconda3/envs/mayavi/lib/python3.6/site-packages/traits/traits.py in __call__(self, *args, **metadata)
    520 
    521     def __call__ ( self, *args, **metadata ):
--> 522         return self.maker_function( *args, **metadata )
    523 
    524 class TraitImportError ( TraitFactory ):

~/miniconda3/envs/mayavi/lib/python3.6/site-packages/traits/traits.py in Color(*args, **metadata)
   1234     from traitsui.toolkit_traits import ColorTrait
   1235 
-> 1236     return ColorTrait( *args, **metadata )
   1237 
   1238 Color = TraitFactory( Color )

~/miniconda3/envs/mayavi/lib/python3.6/site-packages/traitsui/toolkit_traits.py in ColorTrait(*args, **traits)
      5 
      6 def ColorTrait ( *args, **traits ):
----> 7     return toolkit().color_trait( *args, **traits )
      8 
      9 def RGBColorTrait ( *args, **traits ):

~/miniconda3/envs/mayavi/lib/python3.6/site-packages/traitsui/toolkit.py in toolkit(*toolkits)
    150     if ETSConfig.toolkit:
    151         # If a toolkit has already been set for ETSConfig, then use it:
--> 152         _toolkit = _import_toolkit(ETSConfig.toolkit)
    153         return _toolkit
    154     else:

~/miniconda3/envs/mayavi/lib/python3.6/site-packages/traitsui/toolkit.py in _import_toolkit(name)
     81 
     82 def _import_toolkit ( name ):
---> 83     return __import__( name, globals=globals(), level=1 ).toolkit
     84 
     85 

~/miniconda3/envs/mayavi/lib/python3.6/site-packages/traitsui/wx/__init__.py in <module>()
     24 #-------------------------------------------------------------------------------
     25 
---> 26 from . import toolkit
     27 
     28 # Reference to the GUIToolkit object for wxPython

~/miniconda3/envs/mayavi/lib/python3.6/site-packages/traitsui/wx/toolkit.py in <module>()
     56     import PythonDropTarget
     57 
---> 58 from .constants \
     59     import WindowColor, screen_dx, screen_dy
     60 

~/miniconda3/envs/mayavi/lib/python3.6/site-packages/traitsui/wx/constants.py in <module>()
     59     BorderedGroupColor = wx.Colour( 224, 224, 224 )
     60 else:
---> 61     WindowColor = wx.SystemSettings_GetColour( wx.SYS_COLOUR_MENUBAR )
     62 
     63 # Standard width of an image bitmap

AttributeError: module 'wx' has no attribute 'SystemSettings_GetColour'
grlee77 commented 7 years ago

When I tried this in linux, the version of wxPython installed was 4.0.0rc1.dev3440+0f9b36e-py36_0 which would seem to be the source of the problem (wxPython 4 is not supported by traitsui). The specific issue is this API change.

It seems like it may be a bug in conda that 4.0.0rc1 is considered as satisfying "<4"? It does not look like conda-forge has a version of wxPython older than this, though. defaults has wxpython 3.0, but only for Python 2.7.

msarahan commented 7 years ago

I've raised this behavior as unintuitive with @mcg1969 before. Prerelease versions are considered less than .0 releases. That's why conda build does its upper bounds as x.y.0a0

I don't know how prerelease versions really should be handled, though. The current way is ok once you know about it, but boy is it confusing until you do.

On Nov 6, 2017 6:30 PM, "Gregory R. Lee" notifications@github.com wrote:

When I tried this in linux, the version of wxPython installed was 4.0.0rc1.dev3440+0f9b36e-py36_0 which would seem to be the source of the problem (wxPython 4 is not supported by traitsui). The specific issue is this API change https://docs.wxpython.org/MigrationGuide.html#static-methods.

It seems like it may be a bug in conda that 4.0.0rc1 is considered as satisfying "<4"? It does not look like conda-forge has a version of wxPython older than this, though. defaults has wxpython 3.0, but only for Python 2.7.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/conda-forge/mayavi-feedstock/issues/16#issuecomment-342334718, or mute the thread https://github.com/notifications/unsubscribe-auth/AACV-aDdWcFVPBCbWwg34OysD0cRqhPcks5sz6SQgaJpZM4QT_1y .

grlee77 commented 7 years ago

Prerelease versions are considered less than .0 releases.

I suspected that might be the explanation, but it seems like most users would naively expect "<4" to give the most recent 3.x release!

@moorepants I should also mention that wxPython 3 does not support Python 3 so the lack of packages there is not a limitation of conda-forge. The only current solution for using Mayavi with a wx backend would appear to be to run Python 2.7. I don't know if enthought is in the progress of updating their tools to use wx 4.0, but as of now it does not appear to be supported in mayavi's dependencies (pyface, traitsui).

mcg1969 commented 7 years ago

Frankly I agree with the intuition here. For some vague reason I seem to remember the relevant PEP standards disagreeing with us here. But if so, maybe we just acknowledge that it is better to violate the standard.

grlee77 commented 7 years ago

For some vague reason I seem to remember the relevant PEP standards disagreeing with us here. But if so, maybe we just acknowledge that it is better to violate the standard.

This section of PEP440 at one point states: The exclusive ordered comparison <V MUST NOT allow a pre-release of the specified version unless the specified version is itself a pre-release. Allowing pre-releases that are earlier than, but not equal to a specific pre-release may be accomplished by using <V.rc1 or similar.

However, later in that document it seems to say that a pre-release will be used if there is no non-prerelease version that matches. I think that would be the case that occurs here (There is only a pre-release of the package available): https://www.python.org/dev/peps/pep-0440/#handling-of-pre-releases

I guess the question is if conda-forge had a non pre-release 3.0 package for python 3.0 would that one have been returned instead of 4.0rc1? If so, then it is probably a pretty rarely encountered problem.

moorepants commented 7 years ago

I guess i can just specify wxpython=3.* or something like that.

moorepants commented 7 years ago

Yes, I see now that wxpython is only for python 2.7:

wxpython                     3.0.0.0                  py27_0  defaults        
                             3.0.0.0                  py27_2  defaults        
                             4.0.0a3                  py27_0  conda-forge     
                             4.0.0a3                  py35_0  conda-forge     
                             4.0.0a3                  py36_0  conda-forge     
                             4.0.0b2                  py27_0  conda-forge     
                             4.0.0b2                  py35_0  conda-forge     
                             4.0.0b2                  py36_0  conda-forge     
                             4.0.0rc1.dev3440+0f9b36e          py27_0  conda-forge     
                          *  4.0.0rc1.dev3440+0f9b36e          py35_0  conda-forge     
                             4.0.0rc1.dev3440+0f9b36e          py36_0  conda-forge     

I can run Python 2.7.

moorepants commented 7 years ago

Why are prereleases even in a my conda-forge channel? Shouldn't they only be accessible if I want to install prereleases? Seems like we should keep prereleases hidden to endusers by default.

larsoner commented 2 years ago

Closing as the original issue seems to be due to not having GL rendering setup (e.g., with xvfb). We can reopen if people are still having problems with this, but I think it's likely to be a Mayavi/headless rendering issue rather than one with the recipe itself