-1

注意:已找到临时解决方案:打开camera.py、使用pass并注释函数中的内容,_view_plane_normal_changed然后重新编译。

我正在使用python(x,y)2.7.5.1. 当我使用一些使用 tvtk 的软件包(如 mayavi)时,它会引发一个AttributeError:SetViewPlaneNormal. 我知道这是因为 vtk 已弃用此方法。有谁知道如何解决它?的版本vtk5.10.1-3. 完整的引用包含一些这样的块:

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.
4

2 回答 2

1

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

我的平台是 Win 7 Pro x64,带有 Python 2.7.5、VTK 5.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])
于 2013-11-06T15:09:50.570 回答
0

我在使用 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()
于 2014-01-07T09:17:27.193 回答