我正在尝试使用paraview编写一个脚本,该脚本可以自动生成OpenFoam解决方案的特定虚拟化。我正在使用Jupyter Notebook。 我没有单独建立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
我整天花了很多时间在研究这个问题,但无法解决。任何帮助将不胜感激!
答案 0 :(得分:0)
使用conda安装paraview对其进行了修复。您甚至不需要设置路径变量。
conda install -c conda-forge paraview