我正在尝试使用 paraview 编写一个脚本,该脚本自动生成 OpenFoam 解决方案的特定可视化。我正在使用 Jupyter 笔记本。我没有单独建立paraview。它带有“OpenFoam-in-a-box”。我的机器 2.7 和 3.5 上也有 2 个版本的 Python。
鉴于这种情况,我设置了两个路径变量,如下所示:
import sys
username = getpass.getuser()
sys.path.append('/home/'+username+'/OpenFOAM/OpenFOAM-in-Box/OpenFOAM-
in-Box-18.02/ThirdParty-dev/platforms/linux64Gcc62/ParaView-
5.4.1/lib/paraview-5.4/site-packages/')
import paraview
sys.path.append('/home/'+username+'/anaconda2/lib/python2.7/site-
packages')
from paraview.simple import *
这会引发如下错误:
Error: Could not import vtkCommonComputationalGeometry
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-11-35ff85eed6df> in <module>()
4 import paraview
5 sys.path.append('/home/'+username+'/anaconda2/lib/python2.7/site-packages')
----> 6 from paraview.simple import *
/home/username/OpenFOAM/OpenFOAM-in-Box/OpenFOAM-in-Box-18.02/ThirdParty-dev/platforms/linux64Gcc62/ParaView-5.4.1/lib/paraview-5.4/site-packages/paraview/simple.py in <module>()
41
42 import paraview
---> 43 from paraview import servermanager
44 import paraview._backwardscompatibilityhelper
45
/home/username/OpenFOAM/OpenFOAM-in-Box/OpenFOAM-in-Box-18.02/ThirdParty-dev/platforms/linux64Gcc62/ParaView-5.4.1/lib/paraview-5.4/site-packages/paraview/servermanager.py in <module>()
51 # prefer `vtk` from `paraview` since it doesn't import all
52 # vtk modules.
---> 53 from paraview import vtk
54 from paraview import _backwardscompatibilityhelper as _bc
55
/home/username/OpenFOAM/OpenFOAM-in-Box/OpenFOAM-in-Box-18.02/ThirdParty-dev/platforms/linux64Gcc62/ParaView-5.4.1/lib/paraview-5.4/site-packages/paraview/vtk/__init__.py in <module>()
5 except ImportError:
6 paraview.print_error("Error: Could not import vtkCommonComputationalGeometry")
----> 7 from paraview.vtk.vtkCommonCore import *
8 from paraview.vtk.vtkCommonDataModel import *
9 from paraview.vtk.vtkCommonExecutionModel import *
/home/username/OpenFOAM/OpenFOAM-in-Box/OpenFOAM-in-Box-18.02/ThirdParty-dev/platforms/linux64Gcc62/ParaView-5.4.1/lib/paraview-5.4/site-packages/paraview/vtk/vtkCommonCore.py in <module>()
7 # during build and testing, the modules will be elsewhere,
8 # e.g. in lib directory or Release/Debug config directories
----> 9 from vtkCommonCorePython import *
ImportError: No module named vtkCommonCorePython
我几乎一整天都在研究这个问题,但无法解决这个问题。任何帮助,将不胜感激 !!