在 Qt4 上安装 MayaVi 导致分段错误

发布于 12-09 06:52 字数 2094 浏览 2 评论 0 原文

我正在尝试在我的计算机上安装 MayaVi。我使用的是配备 OS X 10.6.8、4 GB RAM 的 MacBook Air。

我的 python 和大部分堆栈都是通过 Homebrew 或 pip 构建的。特别是对于 python2.7、ipython、Qt4、numpy、scipy、vtk 等来说更是如此。VTK 在 Homebrew 中使用 --python 和 --qt-extern 标志安装,并且所有构建都很好。我没有安装 wxPython,因为我无法通过 pip、手动构建或二进制文件让它工作。

如果我运行 ipython -q4thread,我无法成功执行 from mayavi import mlab,因为我收到与使用 PyQt 的两个不同 API 相关的错误:http://groups.google.com/group/spyderlib/browse_thread/thread/36a35baec74ca144

但是,如果我单独运行 ipython ,我可以成功运行 从 Mayavi 导入 mlab。然后我尝试遵循以下示例: http://github.enthought.com/mayavi/mayavi /example_using_with_scipy.html,其中包括以下命令:

import numpy as np

def V(x, y, z):
    """ A 3D sinusoidal lattice with a parabolic confinement. """
    return np.cos(10*x) + np.cos(10*y) + np.cos(10*z) + 2*(x**2 + y**2 + z**2)

X, Y, Z = np.mgrid[-2:2:100j, -2:2:100j, -2:2:100j]

from mayavi import mlab
mlab.contour3d(X, Y, Z, V)

这一切都正常,我会弹出一个窗口,我可以旋转 3d 绘图等。但是,然后我单击该图标打开管道,这会打开另一个窗口。然后教程说双击“等值面”来更改其属性。一旦我这样做,我就会得到一个可重现的分段错误。

我不知道如何开始找出问题所在。

或者,我可以从命令行运行 MayaVi:mayavi2,然后会弹出 GUI。当我这样做时,我得到以下输出:

Warning: Unable to import the wx backend for pyface due to traceback: Traceback (most recent call last):
      File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/pyface/toolkit.py", line 45, in _init_toolkit
        be = import_toolkit(tk)
      File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/pyface/toolkit.py", line 31, in import_toolkit
        __import__(be + 'init')
      File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/pyface/ui/wx/init.py", line 14, in <module>
        import wx
    ImportError: No module named wx

尽管确实弹出了 GUI,但如果我尝试执行任何操作,则会出现段错误。

如果您对解决此问题有任何想法,或者对成功重新安装软件包有任何指导,请告诉我。

谢谢!

乌里

I am trying to install MayaVi on my computer. I'm on a MacBook Air with OS X 10.6.8, 4 GB RAM.

My python and most of my stack is built through Homebrew or pip. In particular this is true for python2.7, ipython, Qt4, numpy, scipy, vtk, etc. VTK was installed with --python and --qt-extern flags in Homebrew, and all the builds were fine. I do not have wxPython installed, as I failed to get it working through pip, manual building, or the binaries.

If I run ipython -q4thread, I cannot successfully execute from mayavi import mlab as I get an error related to usage of two different APIs for PyQt: http://groups.google.com/group/spyderlib/browse_thread/thread/36a35baec74ca144

However, if I run ipython alone, I can successfully run from mayavi import mlab. Then I try to follow this example: http://github.enthought.com/mayavi/mayavi/example_using_with_scipy.html, which includes these commands:

import numpy as np

def V(x, y, z):
    """ A 3D sinusoidal lattice with a parabolic confinement. """
    return np.cos(10*x) + np.cos(10*y) + np.cos(10*z) + 2*(x**2 + y**2 + z**2)

X, Y, Z = np.mgrid[-2:2:100j, -2:2:100j, -2:2:100j]

from mayavi import mlab
mlab.contour3d(X, Y, Z, V)

This all works fine, and I get a window that pops up and I can rotate the 3d plot etc. However, then I click on the icon to open up the pipeline, which opens another window. The tutorial then says to double-click on the "isosurface" to change its properties. As soon as I do that, I get a reproducible segmentation fault.

I have no idea how to begin to figure out what the problem is.

Alternatively, I can run MayaVi from the command line: mayavi2, and the GUI pops up. When I do so I get the following output:

Warning: Unable to import the wx backend for pyface due to traceback: Traceback (most recent call last):
      File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/pyface/toolkit.py", line 45, in _init_toolkit
        be = import_toolkit(tk)
      File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/pyface/toolkit.py", line 31, in import_toolkit
        __import__(be + 'init')
      File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/pyface/ui/wx/init.py", line 14, in <module>
        import wx
    ImportError: No module named wx

Although the GUI does pop up, if I try to do any operation, I get a segfault.

Please let me know if you have any thoughts on troubleshooting this, or perhaps guidance on reinstalling the package successfully.

Thanks!

Uri

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

゛时过境迁 2024-12-16 06:52:21

我还有一台运行 OS X 10.7.4 (Lion) 的 MacBook Air。二月份我花了很多时间让 Mayavi 工作,最终成功地达到了可以制作科学绘图的程度。这仍然意味着一些示例和测试无法正确运行,并且 GUI 在控制台中生成了大量错误消息,但没有崩溃(大多数情况下)。现在,我设法破坏了我的 Python 安装(可能是通过升级 numpy),所以我需要重新安装。唉,六个月后事情并没有变得更容易!

仍然没有可行的预编译选项。我从这里尝试了 Enthought Python 发行版: http://www.enthought.com/repo/.epd_academic_installers< /a>. Mac 上的 ETS 仍然没有 64 位版本,组件很古老,基于 wxPython 的 Mayavi 看起来很丑,感觉很慢而且反应迟钝。回到 brewpip。经过大量的试验和错误,以下是或多或少有效的方法:

1. 先决条件

隐藏/卸载损坏的 Homebrew Python 安装:

mv /usr/local/lib/python2.7/site-packages /usr/local/lib/python2.7/site-packages-old 
mv /usr/local/share/python /usr/local/share/python-old
brew uninstall python pyqt pyside vtk

从 Xcode (4.4.1) 中,选择 llvm-gcc 作为编译器(我用 clang 不太成功):

cd /usr/bin
sudo rm cc c++
sudo ln -s gcc cc
sudo ln -s g++ c++

2. 安装

2.1 Python

brew install python --framework --universal

指向新安装:

cd /System/Library/Frameworks/Python.framework/Versions
rm Current
ln -s /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/Current .

如果安装了 EPD,则需要在/Library/Frameworks/Python.framework/Versions,否则 EPD 将优先。

2.2 Numpy

从源代码安装 numpy (pip 1.2 目前无法正确安装 npymath.ini,这将导致 scipy 无法构建):

git clone https://github.com/numpy/numpy.git
cd numpy
git checkout v1.6.2
python setup.py install

由于有如此多的包链接到 numpy,我强烈建议您查看今天发布的正式版本 1.6.2。接下来使 numpy 标头可见:

cd /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7
ln -s /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy .

2.3 qt、pyqt、vtk

安装 qt (4.8.2) 和 pyqt (4.9.4):

brew install qt
brew install pyqt

也可以安装 pyside (1.1.1),

brew install pyside

但这似乎会产生更多崩溃 与 Mayavi。无论如何,请附加

export QT_API=pyqt

.bashrc 以避免任何混淆。接下来安装 vtk(5.10.0;5.8.0 也可以)

brew install vtk --python --tcl --examples --qt

...然后等待(编译大约需要 40 分钟)。 --qt 标志并不是绝对必要的,但也没有什么坏处。

接下来,从 http://www.vtk 下载 vtk 数据.org/files/release/5.10/vtkdata-5.10.0.tar.gz,在某处解压并获得 VTK_DATA_ROOT 环境变量指向VTKData目录。 启动 TCL 示例中的一些示例

/usr/local/share/vtk/Examples

使用 python .py 启动 python 示例和使用 vtk 。工作起来绝对漂亮,对吧?那么接下来让我们看看 Mayavi 如何把这一切搞砸了...

2.4 ETS 和 Mayavi

虽然

pip install mayavi

可以让您有所收获,但它似乎比从 github 安装前沿技术会产生更多的崩溃。获取 https://github.com/enthought/ets/raw/master/ets。 py 并运行

python ets.py clone

以克隆 ETS git 存储库。您只需要 apptoolsmayavipyfacetraitstraitsui,可能 < code>envisage 如果您想从命令行运行 mayavi2。因此,删除其他目录并执行

python ets.py develop

此操作应该允许您通过运行 mayavi/examples/tvtkmayavi/examples/mayavi 来运行存储库中的一些示例>python .py 并使用 GUI 进行操作。有很多控制台错误和很多 GUI 功能不起作用,例如选择 LUT 表。但希望它不会崩溃。

2.5 scipy、matplotlib、ipython

我更喜欢从 github 获取 scipy 和 matplotlib 的最新技术。首先使用 brew 安装所有依赖项。然后

git clone https://github.com/scipy/scipy.git
cd scipy
python setup.py install

git clone https://github.com/matplotlib/matplotlib.git
cd matplotlib
python setup.py install

使用pip安装ipython (0.13)。首先安装 qtconsole:

pip install pygments
pip install pyzmq

然后

pip install ipython

有几种可能的方法来启动 ipython 与 mayavi 一起使用,具体取决于谁控制 QT 事件循环:

  • ipython without mlab.show():挂起。
  • ipythonmlab.show():可以工作,但提示可能会变得无响应。
  • ipython --gui=qtipython --pylab=qt:可以工作,但“保存”对话框会立即关闭。
  • 没有 mlab.show()ipython qtconsole:挂起。
  • ipython qtconsolemlab.show():有效。
  • ipython qtconsole --gui=qtipython qtconsole --pylab=qt:有效。

祝你好运!

I also have a MacBook Air with OS X 10.7.4 (Lion). I spent a lot of time back in February to get mayavi working, eventually succeeding to a point where I could produce scientific plots. That still means that some of the examples and tests wouldn't run correctly, and the GUI produced lots of error messages in the console, but didn't crash (most of the time). Now, I managed to break my Python installation (probably by upgrading numpy), so I needed to reinstall. Alas, it didn't get any easier 6 months later!

There is still no viable precompiled option. I tried the Enthought Python Distribution from here: http://www.enthought.com/repo/.epd_academic_installers. Still no 64 bit version with ETS for Mac, components are ancient, mayavi based on wxPython looks ugly and feels slow and unresponsive. So back to brew and pip. After a lot of trial and error, here is what worked more or less:

1. Prerequisites

Hide/uninstall the broken Homebrew Python installation:

mv /usr/local/lib/python2.7/site-packages /usr/local/lib/python2.7/site-packages-old 
mv /usr/local/share/python /usr/local/share/python-old
brew uninstall python pyqt pyside vtk

From Xcode (4.4.1), choose llvm-gcc as the compiler (I had less success with clang):

cd /usr/bin
sudo rm cc c++
sudo ln -s gcc cc
sudo ln -s g++ c++

2. Installation

2.1 Python

brew install python --framework --universal

Point to the new installation:

cd /System/Library/Frameworks/Python.framework/Versions
rm Current
ln -s /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/Current .

If the EPD is installed, one needs to do the same in /Library/Frameworks/Python.framework/Versions, otherwise the EPD will take priority.

2.2 Numpy

Install numpy from source (pip 1.2 currently doesn't install npymath.ini correctly, which will make scipy fail to build):

git clone https://github.com/numpy/numpy.git
cd numpy
git checkout v1.6.2
python setup.py install

Since so many packages link against numpy, I really recommend checking out an official release, 1.6.2 as of today. Next make the numpy headers visible:

cd /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7
ln -s /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy .

2.3 qt, pyqt, vtk

Install qt (4.8.2) and pyqt (4.9.4):

brew install qt
brew install pyqt

One can also install pyside (1.1.1)

brew install pyside

but this appears to produce more crashes with mayavi. In any case, append

export QT_API=pyqt

to .bashrc to avoid any mixups. Next install vtk (5.10.0; 5.8.0 works just as well)

brew install vtk --python --tcl --examples --qt

...and wait (compilation takes around 40 minutes). The --qt flag isn't strictly necessary, but it doesn't harm either.

Next, download vtk data from http://www.vtk.org/files/release/5.10/vtkdata-5.10.0.tar.gz, unpack somewhere and have the VTK_DATA_ROOT environment variable point to the VTKData directory. Run some examples in

/usr/local/share/vtk/Examples

Launch python examples with python <example>.py and TCL examples with vtk <example.tcl>. Works absolutely beautifully, right? So let's see how mayavi messes it all up next...

2.4 ETS and mayavi

Although

pip install mayavi

gets you somewhere, it appears to produce more crashes than installing the bleeding edge from github. Get https://github.com/enthought/ets/raw/master/ets.py and run

python ets.py clone

to clone the ETS git repository. You only need apptools, mayavi, pyface, traits and traitsui, possibly envisage if you want to run mayavi2 from the command line. So delete the other directories and do

python ets.py develop

This should allow you to run some of the examples in the repository in mayavi/examples/tvtk and mayavi/examples/mayavi by running python <example>.py and play around with the GUI. There are lots of console errors and lots of GUI features that don't work, like selecting a LUT table. But it hopefully doesn't crash.

2.5 scipy, matplotlib, ipython

I prefer to get the bleeding edge from github for scipy and matplotlib. First install all dependencies using brew. Then

git clone https://github.com/scipy/scipy.git
cd scipy
python setup.py install

git clone https://github.com/matplotlib/matplotlib.git
cd matplotlib
python setup.py install

Then install ipython (0.13) using pip. For the qtconsole install first:

pip install pygments
pip install pyzmq

then

pip install ipython

There are a few possible ways to launch ipython for use with mayavi, depending on who controls the QT event loop:

  • ipython without mlab.show(): Hangs.
  • ipython with mlab.show(): Works, but prompt may become unresponsive.
  • ipython --gui=qt or ipython --pylab=qt: Works, but "Save" dialog closes immediately.
  • ipython qtconsole without mlab.show(): Hangs.
  • ipython qtconsole with mlab.show(): Works.
  • ipython qtconsole --gui=qt or ipython qtconsole --pylab=qt: Works.

Good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文