Unable to Load Visualization into Mayavi2 UI with envisage backend

108 views Asked by At

I created a visualization using mayavi2/mlab in Python and I need a way to share it with my supervisor. He doesn't have any programming skills, so I want him to simply open the model with all the planes and colors that I created and be able to play around with it.

I did this in Python to save it to a file:

engine = mlab.get_engine()
engine.save_visualization('./Results/3DModel.mv2')

When I try to open '3DModel.mv2' using the Mayavi2 (envisage backend) user interface via 'File > Load Visualization' I get this exception:

Exception
In /usr/local/lib/python2.7/dist-packages/apptools/persistence/state_pickler.py:924
TypeError: Given object is neither a file or String (in _get_file_read)

Thanks in advance!

1

There are 1 answers

0
DimonWeb On

I don't know why these functions works such way but I have modified the source file state_pickler.py and delete state_pickler.pyc:

def _get_file_read(f):
    if hasattr(f, 'read'):
        return f
    else:
        return open(f, 'rb')

def _get_file_write(f):
    if hasattr(f, 'write'):
        return f
    else:
        return open(f, 'wb')

And now it is working. The type of f was unicode.