0

我正在尝试使用 Mayavi mlab 库中的网格函数 - 但每次运行代码时,程序都会崩溃。

我正在运行的代码只是文档中给出的示例的略微修改版本。

import numpy as np
from numpy import sin, cos
from mayavi import mlab

def main():

    PI = np.pi

    mlab.clf()
    phi, theta = np.mgrid[0:PI:11j, 0:2 * PI:11j]
    x = sin(phi) * cos(theta)
    y = sin(phi) * sin(theta)
    z = cos(phi)

    mlab.mesh(x, y, z, representation='wireframe', color=(0, 0, 0))

    mlab.show()

if __name__ == '__main__':
    main()

程序加载 Mayavi 绘图窗口,然后崩溃并出现以下错误:

  • 进程以退出代码 -1073741795 (0xC000001D) 结束

我在用:

  • Windows 7 旗舰版 - 64 位

  • 适用于 Python 2.7 的 Anaconda 2 安装

  • PyCharm 社区版 2017.1.1

我已经尝试了 mlab.mesh 的其他基本代码示例,结果相同。

我已经使用 mlab.plot3d 运行了其他 Mayavi 脚本,没有任何问题。

4

1 回答 1

0

删除表示 ='wireframe' 解决了我的问题。IE

mlab.mesh(x, y, z, color=(0, 0, 0))

唯一完全有效的“表示”是“表面”,这是默认设置。

'mesh' 和 'fancymesh' 都可以工作,但会在 Mayavi 界面中产生警告。

'points' 和 'wireframe' 都使 python 崩溃。

这些表示在文档[此处]中进行了描述

于 2017-04-18T10:42:59.610 回答