用于 OpenFoam 的 jupyter notebook 中的 Paraview:没有名为 vtkCommonCorePython 的模块
Posted
技术标签:
【中文标题】用于 OpenFoam 的 jupyter notebook 中的 Paraview:没有名为 vtkCommonCorePython 的模块【英文标题】:Paraview in jupyter notebook for OpenFoam: No module named vtkCommonCorePython 【发布时间】:2018-09-06 00:04:58 【问题描述】:我正在尝试使用 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
我几乎一整天都在研究这个问题,但无法解决这个问题。任何帮助将不胜感激!
【问题讨论】:
我遇到了同样的问题,我解决了问题here。 【参考方案1】:使用 conda 安装 paraview 修复了它。您甚至不需要设置路径变量。
conda install -c conda-forge paraview
【讨论】:
以上是关于用于 OpenFoam 的 jupyter notebook 中的 Paraview:没有名为 vtkCommonCorePython 的模块的主要内容,如果未能解决你的问题,请参考以下文章
Jupyter command `jupyter-contrib` not found
jupyterlab 打不开?Exception: Jupyter command `jupyter-lab` not found
Ubuntu上jupyter报错:Exception: Jupyter command `jupyter-kernelspec` not found.解决办法
Ubuntu上jupyter报错:Exception: Jupyter command `jupyter-kernelspec` not found.解决办法
jupyter notebook代码补全扩展安装遇到 Jupyter command `jupyter-contrib` not found.” 问题