准备工作:
1. use the same python version as paraview binary was built with. (or build paraview from source using the system python)
2. Set PYTHONPATH to point to a list of directories where paraview stores its python files
3. Set LD_LIBRARY_PATH (on Unix or equivalent on other platforms) to point to where paraview stores its DLLs.
After that you can run paraview scripts using the system python and probably with pycharm (if pycharm uses the system python).
目前测试用paraview 5.8.1和Anaconda3,python版本都是3.7.4,但是会产生错误:
#osp: INITIALIZATION ERROR --> could not open module lib ospray_module_ispc: �Ҳ���ָ����ģ�顣
官方论坛说paraview 5.9版本会解决。
参考资料:
https://discourse.paraview.org/t/could-not-open-module-lib-ospray-module-ispc/4079/7
2021.02.06 更新:
目前可以在Pycharm中使用ParaView 5.9,上面的报错官方也已经解决。
准备工作:
1.统一ParaView和系统的Python版本,ParaView 5.9用的是Python 3.8,因此系统的python版本也需安装Python 3.8,建议使用Anaconda安装。
2.配置ParaView相关环境变量
(1)在Path里加入D:\Program Files\ParaView 5.9.0-MPI-Windows-Python3.8-msvc2017-64bit\bin
(2)新创建一个PYTHONPATH的变量,并加入D:\Program Files\ParaView 5.9.0-MPI-Windows-Python3.8-msvc2017-64bit\bin\Lib;D:\Program Files\ParaView 5.9.0-MPI-Windows-Python3.8-msvc2017-64bit\bin\Lib\site-packages;D:\Program Files\ParaView 5.9.0-MPI-Windows-Python3.8-msvc2017-64bit\bin\Lib\site-packages\paraview
测试环境为:
1.系统:win 10专业版
2.IDE:PyCharm Community Edition 2019.3.1 x64
3.测试代码
# 通过Python使用paraview需要加入这个模块
from paraview.simple import *
# 创建一个球体
sphere = Sphere()
# 准备显示球体
Show()
# 渲染
Render()