I'm trying to get Pyinstaller to work with a program that uses pymeshlab. Below is an example python script (main.py) that uses a function I want:
import pymeshlab
import numpy as np
mesh_a_verts = np.array([[0., 0., 0.], [0., 0., 1.], [0., 1., 0.], [0., 1., 1.], [1., 0., 0.],
[1., 0., 1.], [1., 1., 0.], [1., 1., 1.], [0., 0.5, 0.5], [1., 0.5, 0.5]])
mesh_a_faces = np.array([[0, 8, 2], [2, 8, 3], [3, 8, 1], [1, 8, 0], [6, 9, 4], [7, 9, 6], [5, 9, 7],
[4, 9, 5], [2, 6, 4], [2, 4, 0], [3, 7, 6], [3, 6, 2], [1, 5, 7], [1, 7, 3], [0, 4, 5],
[0, 5, 1]], )
mesh_b_verts = np.array([[0.5, 0., 0.], [0.5, 0., 1.], [0.5, 1., 0.], [0.5, 1., 1.], [1.5, 0., 0.],
[1.5, 0., 1.], [1.5, 1., 0.], [1.5, 1., 1.], [0.5, 0.5, 0.5]])
mesh_b_faces = np.array([[0, 8, 2], [2, 8, 3], [3, 8, 1], [1, 8, 0], [7, 5, 4], [6, 7, 4], [2, 6, 4],
[2, 4, 0], [3, 7, 6], [3, 6, 2], [1, 5, 7], [1, 7, 3], [0, 4, 5], [0, 5, 1]])
def main():
ms = pymeshlab.MeshSet()
ms.add_mesh(pymeshlab.Mesh(mesh_a_verts, mesh_a_faces))
ms.add_mesh(pymeshlab.Mesh(mesh_b_verts, mesh_b_faces))
ms.generate_boolean_intersection(first_mesh=0, second_mesh=1)
print(ms.mesh(2).vertex_matrix(), ms.mesh(2).face_matrix())
if __name__ == '__main__':
main()
This runs fine in python, but when I try to bundle it with Pyinstaller and run the generated executable, I get the error:
Traceback (most recent call last):
File "main.py", line 29, in <module>
File "main.py", line 23, in main
AttributeError: 'pymeshlab.pmeshlab.MeshSet' object has no attribute 'generate_boolean_intersection'
[27580] Failed to execute script 'main' due to unhandled exception!
I thought maybe Pyinstaller was missing some dlls, so I put the following in my main.spec, but it didn't help
from pathlib import Path
import pymeshlab
from os import listdir
pmeshlab_plugins_path = Path(pymeshlab.__file__).parent / "lib" / "plugins"
pm_binaries = [(pmeshlab_plugins_path/plugin, "./pymeshlab/lib/plugins") for plugin in listdir(pmeshlab_plugins_path)]
block_cipher = None
a = Analysis(['main.py'],
pathex=[],
binaries=[*pm_binaries],
...
Any thoughts?
The pyinstaller option --collect-all=pymeshlab worked for me. This copies everything from the specified package into the pyinstaller output, so must have copied something that I missed.