如何使用 `pyinstaller` 捆绑 Anaconda 安装的 paraview 包

问题描述 投票:0回答:1

考虑这个 python 测试文件

main.py

# main.py
from paraview.simple import *

def paraTest():
    Cone()
    SetProperties(Resolution=32)
    Shrink()
    Show()
    Render()

if __name__ == '__main__':
    paraTest()

这取决于从 Anaconda 使用安装的

paraview
conda install -c conda-forge paraview
根据 https://anaconda.org/conda-forge/paraview.

直接用 python 运行,程序运行正常。

问题

当我使用带有终端命令的 pyinstaller 打包它时

pyinstaller main.py
,然后运行executable,我得到以下错误:

Traceback (most recent call last):
  File "paraview/__init__.py", line 161, in <module>
ImportError: Failed to load vtkRemotingCore: No module named paraview.modules.vtkPVVTKExtensionsCore

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 1, in <module>
    from paraview.simple import *
  File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module
  File "paraview/__init__.py", line 163, in <module>
ModuleNotFoundError: No module named '_paraview_modules_static'
[14370] Failed to execute script 'main' due to unhandled exception!

我的尝试

我知道可能有一些模块无法被

pyinstaller
识别和包含,所以我将所有模块文件从
{miniconda_root}/miniconda3/lib/python3.9/site-packages/paraview/modules
复制到我的包
{MyPackage_root}/dist/main/paraview/modules
,但同样的错误仍然存在。

环境信息

MacOS 11.2(大苏尔)

python==3.9
paraview==5.9.1
pyinstaller==4.4

提前致谢!

python anaconda pyinstaller paraview
1个回答
0
投票

1.将所有 source/paraview/ 文件复制到您的 dist/paraview.
2.将所有 source/vtkmodules/ 文件复制到你的 dist/vtkmodules.

然后问题就消失了

如果仍然有任何问题,只需将更多文件复制到您的 dist/.

© www.soinside.com 2019 - 2024. All rights reserved.