【发布时间】:2017-06-12 14:30:28
【问题描述】:
我尝试使用以下方法在 macOS(当前运行 Sierra)上设置 Mayavi:
brew install --with-qt5 vtk
brew install mayavi
理论上这应该可行,但现在当我尝试在我的代码中使用 Mayavi 时出现以下错误:
Traceback (most recent call last):
File "test.py", line 32, in <module>
mlab.figure(1, bgcolor=(1, 1, 1), fgcolor=(0, 0, 0), size=(400, 300))
File "/usr/local/lib/python2.7/site-packages/mayavi/tools/figure.py", line 63, in figure
engine = get_engine()
File "/usr/local/lib/python2.7/site-packages/mayavi/tools/engine_manager.py", line 101, in get_engine
return self.new_engine()
File "/usr/local/lib/python2.7/site-packages/mayavi/tools/engine_manager.py", line 146, in new_engine
check_backend()
File "/usr/local/lib/python2.7/site-packages/mayavi/tools/engine_manager.py", line 49, in check_backend
''')
ImportError: Could not import backend for traits
_______________________________________________________________________________
Make sure that you have either the TraitsBackendWx or the TraitsBackendQt
projects installed. If you installed Mayavi with easy_install, try
easy_install <pkg_name>. easy_install Mayavi[app] will also work.
If you performed a source checkout, be sure to run 'python setup.py install'
in Traits, TraitsGUI, and the Traits backend of your choice.
Also make sure that either wxPython or PyQT is installed. wxPython:
http://www.wxpython.org/ PyQT:
http://www.riverbankcomputing.co.uk/software/pyqt/intro
我相信错误在于 Homebrew 仅支持 Qt5 和 PyQT5 而 Mayavi 在后台寻找 PyQT4。有没有办法让 Mayavi 与 PyQT5 一起工作,或者有没有办法用brew 安装 PyQT4?
当然问题可能出在其他地方……
谢谢!
【问题讨论】:
-
另一种方法是使用 wx 代替 qt -> docs.enthought.com/mayavi/mayavi/installation.html 并设置环境变量
export ETS_TOOLKIT=wx值得一试 -
哇...所以通过
brew安装wxPython 似乎已经解决了这个问题。我认为 mayavi 会自动找到任何支持的后端。如果您想让您的评论成为答案,我会接受。谢谢!
标签: python pyqt homebrew mayavi