1

Consider this python test file main.py

# main.py
from paraview.simple import *

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

if __name__ == '__main__':
    paraTest()

that depends on paraview package installed from Anaconda using conda install -c conda-forge paraview according to https://anaconda.org/conda-forge/paraview.

The program works as expected when directly run with python.

The Problem

When I package it using pyinstaller with the Terminal command pyinstaller main.py, and then run the executable, I get the following error:

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!

My Attempts

I understand there may be some modules not recognized and included by pyinstaller, so I copied all module files from {miniconda_root}/miniconda3/lib/python3.9/site-packages/paraview/modules to my package {MyPackage_root}/dist/main/paraview/modules, but the same error persists.

Environment info

MacOS 11.2 (Big Sur)

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

Thanks in advance!

Denny Wey
  • 11
  • 1

1 Answers1

0

1.copy all source/paraview/ file to your dist/paraview.
2.copy all source/vtkmodules/ file to your dist/vtkmodules.

Then the problem disappears.

If still have any problem, just copy more file to your dist/.

Yunnosch
  • 26,130
  • 9
  • 42
  • 54
  • Thank you very much. But I ended up doing it manually (start by calling `python main.py`) to circumvent the problem. I don't have the environment anymore, so we'll have to wait for someone else running into the problem to verify. – Denny Wey May 04 '23 at 13:36