Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python tvtk中的AttributeError关于SetViewPlaneNormal_Python_Vtk_Mayavi - Fatal编程技术网

Python tvtk中的AttributeError关于SetViewPlaneNormal

Python tvtk中的AttributeError关于SetViewPlaneNormal,python,vtk,mayavi,Python,Vtk,Mayavi,注意:找到了一个临时解决方案:打开camera.py,使用pass并注释函数\u view\u plane\u normal\u changed中的内容,然后重新编译 我使用的是python(x,y)2.7.5.1。当我使用像mayavi这样的tvtk软件包时,它会引发一个AttributeError:SetViewPlaneNormal. 我知道这是因为vtk不赞成这种方法。 有人知道怎么解决吗? vtk的版本是5.10.1-3. 完整的trackback包含如下一些块: ERROR:trai

注意:找到了一个临时解决方案:打开
camera.py
,使用
pass
并注释函数
\u view\u plane\u normal\u changed
中的内容,然后重新编译

我使用的是
python(x,y)2.7.5.1
。当我使用像mayavi这样的tvtk软件包时,它会引发一个
AttributeError:SetViewPlaneNormal.
我知道这是因为vtk不赞成这种方法。 有人知道怎么解决吗?
vtk
的版本是
5.10.1-3.
完整的trackback包含如下一些块:

ERROR:traits:Exception occurred in traits notification handler for object:     vtkOpenGLCamera (06F89078)
    Debug: Off
    ...#There are too many lines here


Traceback (most recent call last):
    File "D:\Python27\lib\site-packages\traits\trait_notifiers.py", line 381, in call_3
        self.handler( object, old, new )
    File "D:\Python27\lib\site-packages\tvtk\tvtk_classes.zip\tvtk_classes\camera.py", line 82, in _view_plane_normal_changed
        self._do_change(self._vtk_obj.SetViewPlaneNormal,
AttributeError: SetViewPlaneNormal
Exception occurred in traits notification handler.

我面临着完全相同的问题。任何mayavi代码都会导致
AttributeError:SetViewPlaneNormal
错误

我的平台是Win7Pro x64,带有Python 2.7.5、VTK5.10.1和Mayavi 4.3.0

请注意,即使是官方的python示例也会导致错误,但是尽管控制台中不断打印错误,图形还是正确显示的

以下是完整的堆栈跟踪:

, trait: view_plane_normal, old value: [ 0.57735027  0.57735027  0.57735027], new value: [     0.57735027  0.57735027  0.57735027]
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\traits\trait_notifiers.py", line 381, in call_3
    self.handler( object, old, new )
  File "C:\Python27\lib\site-packages\tvtk\tvtk_classes.zip\tvtk_classes\camera.py", line 82, in     _view_plane_normal_changed
    self._do_change(self._vtk_obj.SetViewPlaneNormal,
AttributeError: SetViewPlaneNormal
Exception occurred in traits notification handler for object: vtkOpenGLCamera (092BF010)
  Debug: Off
  Modified Time: 890617
  Reference Count: 2
  Registered Events: 
    Registered Observers:
      vtkObserver (0A1AA3C8)
        Event: 33
        EventName: ModifiedEvent
        Command: 0A867210
        Priority: 0
        Tag: 1
  ClippingRange: (1.56289, 5.47286)
  DirectionOfProjection: (-0.57735, -0.57735, -0.57735)
  Distance: 3.29037
  EyeAngle: 2
  FocalDisk: 1
  FocalPoint: (1, 1, 1)
  ViewShear: (0, 0, 1)
  ParallelProjection: Off
  ParallelScale: 0.851612
  Position: (2.8997, 2.8997, 2.8997)
  Stereo: Off
  Left Eye: 1
  Thickness: 3.90998
  ViewAngle: 30
  UseHorizontalViewAngle: 0
  UserTransform: (none)
(none)
  ViewPlaneNormal: (0.57735, 0.57735, 0.57735)
  ViewUp: (0, 0, 1)
  WindowCenter: (0, 0)
  UseOffAxisProjection: (0)
  ScreenBottomLeft: (-0.5, -0.5, -0.5)
  ScreenBottomRight: (0.5, -0.5, -0.5)
  ScreenTopRight: (0.5, 0.5, -0.5)
  EyeSeparation: (0.06)
  WorldToScreenMatrix: (03996300
    Debug: Off
    Modified Time: 881548
    Reference Count: 1
    Registered Events: (none)
    Elements:
        1 0 0 0 
        0 1 0 0 
        0 0 1 0 
        0 0 0 1 
  )
  EyeTransformMatrix: (039954F0
    Debug: Off
    Modified Time: 881550
    Reference Count: 1
    Registered Events: (none)
    Elements:
        1 0 0 0 
        0 1 0 0 
        0 0 1 0 
        0 0 0 1 
  )
  ModelTransformMatrix: (039955E0
    Debug: Off
    Modified Time: 881552
    Reference Count: 1
    Registered Events: (none)
    Elements:
        1 0 0 0 
        0 1 0 0 
        0 0 1 0 
        0 0 0 1 
  )

, trait: view_plane_normal, old value: [ 0.57735027  0.57735027  0.57735027], new value: [     0.57735027  0.57735027  0.57735027]
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\traits\trait_notifiers.py", line 381, in call_3
    self.handler( object, old, new )
  File "C:\Python27\lib\site-packages\tvtk\tvtk_classes.zip\tvtk_classes\camera.py", line 82, in     _view_plane_normal_changed
    self._do_change(self._vtk_obj.SetViewPlaneNormal,
AttributeError: SetViewPlaneNormal    
上述堆栈跟踪在每次渲染时打印数次。如果我们移动摄像机导致FPS大量下降,就会继续发生这种情况

导致此错误的最简单代码示例:

from mayavi import mlab
mlab.points3d([1], [1], [1])

我在使用python(x,y)(2.7.5.2)时也遇到了这个问题,但在Anaconda(1.8.0)发行版下,代码工作正常

# code comes from mayavi docs shipped with python(x,y) 2.7.5.2
# Create the data.
from numpy import pi, sin, cos, mgrid
dphi, dtheta = pi/250.0, pi/250.0
[phi,theta] = mgrid[0:pi+dphi*1.5:dphi,0:2*pi+dtheta*1.5:dtheta]
m0 = 4; m1 = 3; m2 = 2; m3 = 3; m4 = 6; m5 = 2; m6 = 6; m7 = 4;
r = sin(m0*phi)**m1 + cos(m2*phi)**m3 + sin(m4*theta)**m5 + cos(m6*theta)**m7
x = r*sin(phi)*cos(theta)
y = r*cos(phi)
z = r*sin(phi)*sin(theta)

# View it.
from mayavi import mlab
s = mlab.mesh(x, y, z)
mlab.show()

您能展示一些与问题相关的代码吗?这些代码例如:来自mayavi.mlab import test\u surf;test_surf()请显示完整的回溯。我已编辑了问题。谢谢。我无法重现您的错误<代码>测试冲浪()在我的设置中正常工作。如果您没有提供完整的堆栈跟踪,更不用说关于您的系统的相关信息(如后端、操作系统和python发行版),您希望有人如何调试您的问题?请注意,有几个人遇到了这个问题,但没有人找到解决方案。我找到了一种消除错误的方法,但它相当脏:在
PythonDIR\Lib\site packages\tvtk\u classes.zip\tvtk\u classes\camera.py
edit function
\u view\u plane\u normal\u changed
(第81行),注释
self.\u do\u change(self.\u vtk\u obj.setview\u plane\u normal)
和添加
返回
。这个解决方案确实是暂时的,我仍然在寻找干净的解决方案!