python:导入mayavi.mlab会产生语法错误 [英] python: Importing mayavi.mlab produces syntax error

查看:887
本文介绍了python:导入mayavi.mlab会产生语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用mayavi创建3d图,但是在运行python脚本时出现以下错误:

Im trying to use mayavi to create 3d plots but when running my python script I get the following error:

 Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import mayavi.mlab
  File "C:\Python37\lib\site-packages\mayavi\mlab.py", line 15, in <module>
    from mayavi.core.common import process_ui_events
  File "C:\Python37\lib\site-packages\mayavi\core\common.py", line 16, in <module>
    from apptools.persistence.state_pickler import create_instance
  File "C:\Python37\lib\site-packages\apptools\persistence\state_pickler.py", line 1210

    ^
SyntaxError: invalid syntax

我要测试的功能:

  def create_3D(dataset):
    #Extract the x, y ,z and von mises data from the numpy dataset and create an array for each.
    xs = dataset[:,1]
    ys = dataset[:,2]
    zs = dataset[:,3]
    v = dataset[:,4]

    # Define the points in 3D space
    # including color code based on value v
    pts = mlab.points3d(xs, ys, zs , v)

    # Triangulate based on X, Y with Delaunay 2D algorithm.
    # Save resulting triangulation.
    mesh = mlab.pipeline.delaunay2d(pts)

    # Remove the point representation from the plot
    pts.remove()

    # Draw a surface based on the triangulation
    surf = mlab.pipeline.surface(mesh)

    # Simple plot.
    mlab.xlabel("x")
    mlab.ylabel("y")
    mlab.zlabel("z")
    mlab.show()

有什么主意我可以解决这个问题吗? 我按照建议的安装过程在此处 $ pip install mayavi

Any idea how I could fix this? I followed the installation procedure suggested here $ pip install mayavi

$ pip install PyQt5

我正在使用64位版本的python 3.7

I am using a 64bit version of python 3.7

推荐答案

state_pickler.py只有1022行,没有1210行.

state_pickler.py is only 1022 lines long, it doesn't have line 1210.

删除目录C:\Python37\lib\site-packages\apptools\persistence\__pycache__,然后重试.

尝试重新安装apptools:

pip install -U apptools

这篇关于python:导入mayavi.mlab会产生语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆