简体   繁体   English

Pyinstaller 和 Pymeshlab

[英]Pyinstaller and Pymeshlab

I'm trying to get Pyinstaller to work with a program that uses pymeshlab.我试图让 Pyinstaller 与使用 pymeshlab 的程序一起工作。 Below is an example python script (main.py) that uses a function I want:下面是一个示例 python 脚本 (main.py),它使用我想要的 function:

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:这在 python 中运行良好,但是当我尝试将它与 Pyinstaller 捆绑并运行生成的可执行文件时,出现错误:

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我想也许 Pyinstaller 缺少一些 dll,所以我将以下内容放在我的 main.spec 中,但它没有帮助

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. pyinstaller 选项 --collect-all=pymeshlab 对我有用。 This copies everything from the specified package into the pyinstaller output, so must have copied something that I missed.这会将指定的 package 中的所有内容复制到 pyinstaller output 中,因此一定复制了我遗漏的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM