简体   繁体   中英

Mayavi hangs under Jupyter QtConsole

After installing Mayavi from Christoph Gohlke's Python builds for Windows site , the following works from a plain interactive Python prompt:

import mayavi.mlab as MM
MM.test_surf()

But when I ran the same under jupyter-qtconsole , the window comes up and hangs.


For reference, I have the following packages, installed in the order given, from the above website, over a fresh Python 2.7.13 install.

(These are just the dependencies to get a working environment with Jupyter, SciPy, matplotlib, Mayavi and just a couple of useful extras.)

  • numpy-1.11.1+mkl-cp27-cp27m-win32.whl
  • MS VS 2008 redistributable (from MS website)
  • Pygments-2.1.3-py2.py3-none-any.whl
  • traits-4.6.0-cp27-cp27m-win32.whl
  • PyQt4-4.11.4-cp27-none-win32.whl
  • VTK-5.10.1+qt486-cp27-none-win32.whl
  • mayavi-4.3.1+vtk510-cp27-none-win32.whl
  • pyzmq-15.4.0-cp27-cp27m-win32.whl
  • certifi-2016.8.8-py2.py3-none-any.whl
  • backports.ssl_match_hostname-3.5.0.1-py2-none-any.whl
  • tornado-4.4.1-cp27-cp27m-win32.whl
  • MarkupSafe-0.23-cp27-none-win32.whl
  • Jinja2-2.8-py2.py3-none-any.whl
  • mistune-0.7.3-cp27-cp27m-win32.whl
  • pytz-2016.6.1-py2.py3-none-any.whl
  • pyparsing-2.1.8-py2.py3-none-any.whl
  • cycler-0.10.0-py2.py3-none-any.whl
  • Pillow-3.3.1-cp27-cp27m-win32.whl
  • wxPython_common-3.0.2.0-py2-none-any.whl
  • wxPython-3.0.2.0-cp27-none-win32.whl
  • python_dateutil-2.5.3-py2.py3-none-any.whl
  • PySide-1.2.2-cp27-none-win32.whl
  • matplotlib-2.0.0b3-cp27-cp27m-win32.whl
  • scandir-1.5-cp27-cp27m-win32.whl
  • ipython-5.1.0-py2.py3-none-any.whl
  • ipykernel-4.4.1-py2.py3-none-any.whl
  • ipyparallel-5.2.0-py2.py3-none-any.whl
  • ipywidgets-5.2.2-py2.py3-none-any.whl
  • jupyter-1.0.0-py2.py3-none-any.whl
  • scipy-0.18.0-cp27-cp27m-win32.whl
  • Bottleneck-1.1.0-cp27-cp27m-win32.whl
  • numexpr-2.6.1-cp27-cp27m-win32.whl
  • pandas-0.18.1-cp27-cp27m-win32.whl
  • sympy-1.0-py2.py3-none-any.whl

I found a solution in this thread . This works from within Jupyter QTconsole:

import mayavi.mlab as MM
%gui qt
MM.test_surf()

Note that the %gui qt command has to be issued after importing Mayavi.

(The explanation is that it "initialises Qt event loop support", not that this makes much sense to me.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM