我正在使用Fipy(https://www.ctcms.nist.gov/fipy/)对3D扩散进行建模。
使用Mayavi渲染环境时出现错误。我的代码:
from fipy import Viewer, TransientTerm, DiffusionTerm, CellVariable, Grid3D, Variable, MayaviClient, numerix
nx=20
ny=nx
nz= nx
dx=1.
dy=dx
dz = dx
L=dx*nx
mesh=Grid3D(dx=dx,dy=dy,nx=nx,ny=ny, dz=dz, nz=nz)
phi=CellVariable(name="solutionvariable",
mesh=mesh,
value=0.)
D=1.
eq=TransientTerm()==DiffusionTerm(coeff=D)
# Mayavi viewer
x, y, z = mesh.cellCenters
xyzVar = CellVariable(mesh=mesh, name=r"x y z", value=x * y * z)
k = Variable(name="k", value=0.)
viewer = MayaviClient(vars=numerix.sin(k * xyzVar),limits={'ymin': 0.1, 'ymax': 0.9},datamin=-0.9, datamax=2.0,title="MayaviClient test")
# End of Mayavi viewer
steps = 100
for step in range(steps):
k.setValue(step)
#eq.solve(var=phi,dt=1)
viewer.plot()
完整错误堆栈:
/home/dario/anaconda2/envs/panaxea/bin/python /home/dario/phdCode/fipym/3dexample.py
22:17:18: Debug: Adding duplicate image handler for 'Windows bitmap file'
22:17:18: Debug: Adding duplicate image handler for 'Windows bitmap file'
/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/pyface/ui/wx/clipboard.py:24: wxPyDeprecationWarning: Call to deprecated item. Use wx.DataFormat instead.
PythonObjectFormat = wx.CustomDataFormat('PythonObject')
/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/pyface/wx/drag_and_drop.py:94: wxPyDeprecationWarning: Call to deprecated item. Use wx.DataFormat instead.
PythonObject = wx.CustomDataFormat('PythonObject')
viewer: NOT READY
viewer: NOT READY
Exception occurred in traits notification handler.
Please check the log file for details.
Exception occurred in traits notification handler for object: <mayavi.plugins.mayavi_ui_plugin.MayaviUIPlugin object at 0x7f300dfb67d0>, trait: application, old value: None, new value: <mayavi.plugins.mayavi_workbench_application.MayaviWorkbenchApplication object at 0x7f300dfb6ad0>
Traceback (most recent call last):
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/traits/trait_notifiers.py", line 576, in _dispatch_change_event
self.dispatch( handler, *args )
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/traits/trait_notifiers.py", line 482, in dispatch
handler( *args )
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/traits/traits_listener.py", line 467, in handle_simple
self.next.register( new )
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/traits/traits_listener.py", line 433, in register
value = getattr( self, type )( new, name, False )
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/traits/traits_listener.py", line 701, in _register_simple
return next.register( getattr( object, name ) )
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/envisage/ui/workbench/workbench_application.py", line 132, in _gui_default
return GUI(splash_screen=self.splash_screen)
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/pyface/ui/wx/gui.py", line 60, in __init__
self._splash_screen.open()
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/pyface/i_splash_screen.py", line 79, in open
super(MSplashScreen, self).open()
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/pyface/i_window.py", line 166, in open
self._create()
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/pyface/i_widget.py", line 112, in _create
self.control = self._create_control(self.parent)
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/pyface/ui/wx/splash_screen.py", line 69, in _create_control
splash_screen = wx.SplashScreen(
AttributeError: 'module' object has no attribute 'SplashScreen'
Exception occurred in traits notification handler for object: <__main__.MayaviDaemon object at 0x7f300dff2890>, trait: application, old value: None, new value: <mayavi.plugins.mayavi_workbench_application.MayaviWorkbenchApplication object at 0x7f300dfb6ad0>
Traceback (most recent call last):
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/traits/trait_notifiers.py", line 576, in _dispatch_change_event
self.dispatch( handler, *args )
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/traits/trait_notifiers.py", line 482, in dispatch
handler( *args )
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/traits/traits_listener.py", line 467, in handle_simple
self.next.register( new )
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/traits/traits_listener.py", line 433, in register
value = getattr( self, type )( new, name, False )
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/traits/traits_listener.py", line 701, in _register_simple
return next.register( getattr( object, name ) )
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/envisage/ui/workbench/workbench_application.py", line 132, in _gui_default
return GUI(splash_screen=self.splash_screen)
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/pyface/ui/wx/gui.py", line 60, in __init__
self._splash_screen.open()
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/pyface/i_splash_screen.py", line 79, in open
super(MSplashScreen, self).open()
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/pyface/i_window.py", line 166, in open
self._create()
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/pyface/i_widget.py", line 112, in _create
self.control = self._create_control(self.parent)
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/pyface/ui/wx/splash_screen.py", line 69, in _create_control
splash_screen = wx.SplashScreen(
AttributeError: 'module' object has no attribute 'SplashScreen'
Traceback (most recent call last):
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/FiPy-3.1.3.dev351+gb648878-py2.7.egg/fipy/viewers/mayaviViewer/mayaviDaemon.py", line 349, in <module>
main(sys.argv[1:])
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/FiPy-3.1.3.dev351+gb648878-py2.7.egg/fipy/viewers/mayaviViewer/mayaviDaemon.py", line 345, in main
m.main(argv)
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/mayavi/plugins/app.py", line 195, in main
app.run()
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/mayavi/plugins/mayavi_workbench_application.py", line 73, in run
gui = self.gui
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/envisage/ui/workbench/workbench_application.py", line 132, in _gui_default
return GUI(splash_screen=self.splash_screen)
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/pyface/ui/wx/gui.py", line 60, in __init__
self._splash_screen.open()
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/pyface/i_splash_screen.py", line 79, in open
super(MSplashScreen, self).open()
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/pyface/i_window.py", line 166, in open
self._create()
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/pyface/i_widget.py", line 112, in _create
self.control = self._create_control(self.parent)
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/pyface/ui/wx/splash_screen.py", line 69, in _create_control
splash_screen = wx.SplashScreen(
AttributeError: 'module' object has no attribute 'SplashScreen'
ERROR: In /work/standalone-x64-build/VTK-source/IO/Legacy/vtkDataWriter.cxx, line 180
vtkUnstructuredGridWriter (0x7faddef29700): Unable to open file: /tmp/tmpOkt32j/cell.vtk
Traceback (most recent call last):
File "/home/dario/phdCode/fipym/3dexample.py", line 12, in <module>
viewer.plot()
File "/home/dario/anaconda2/envs/panaxea/lib/python2.7/site-packages/FiPy-3.1.3.dev351+gb648878-py2.7.egg/fipy/viewers/mayaviViewer/mayaviClient.py", line 186, in plot
lock = file(self.vtklockfname, 'w')
IOError: [Errno 2] No such file or directory: '/tmp/tmpOkt32j/lock'
Exception OSError: (2, 'No such file or directory', '/tmp/tmpOkt32j') in <bound method MayaviClient.__del__ of <fipy.viewers.mayaviViewer.mayaviClient.MayaviClient object at 0x7faddddf1c50>> ignored
Process finished with exit code 1
安装说明(https://docs.enthought.com/mayavi/mayavi/installation.html)要求:
我相信我既有pip list
产生的地方:
Package Version Location
----------------------------- --------------------- ------------------------
appdirs 1.4.3
apptools 4.4.0
backports.functools-lru-cache 1.5
certifi 2018.4.16
chardet 3.0.4
configobj 5.0.6
cycler 0.10.0
envisage 4.6.0
FiPy 3.1.3.dev351+gb648878
future 0.16.0
gist 0.0.8
idna 2.7
kiwisolver 1.0.1
matplotlib 2.2.2
mayavi 4.6.0
meshio 2.0.4
numpy 1.14.5
pip 10.0.1
pipdate 0.3.1
pyface 6.0.0
pyglet 1.3.2
Pygments 2.2.0
pygmsh 4.3.4
pyparsing 2.2.0
Pypubsub 4.0.0
pysparse 1.3.dev0 /home/dario/src/pysparse
python-dateutil 2.7.3
pytz 2018.5
requests 2.19.1
scipy 1.1.0
setuptools 39.2.0
six 1.11.0
subprocess32 3.5.2
traits 4.6.0
traitsui 6.0.0
typing 3.6.4
urllib3 1.23
vtk 8.1.1
wheel 0.31.1
wxPython 4.0.3
我觉得我的安装肯定有问题,但似乎无法弄清楚。我正在运行Ubuntu 14.04.3 LTS,它是通过IntelliJ 2017.2。的Python 2.7(Anaconda 2)。