[英]Meshlab script works from Python venv, but not after pyinstaller
I have a simple Python script Mesher.py
which takes file name strings in Windows format on the command line and runs MeshLab on the input point cloud (.xyz file):我有一个简单的 Python 脚本
Mesher.py
,它在命令行上采用 Windows 格式的文件名字符串,并在输入点云(.xyz 文件)上运行 MeshLab:
import sys
from pathlib import Path
import pymeshlab as ml
xyz_file = Path(sys.argv[1]).as_posix()
output_file = Path(sys.argv[2]).as_posix()
ms = ml.MeshSet()
ms.load_new_mesh(xyz_file)
ms.load_filter_script('filters.mlx')
ms.apply_filter_script()
ms.save_current_mesh(output_file)
It runs fine from the Python 3.9.6 interpreter in a virtual environment, but when I package it with pyinstaller (also installed to the venv) to make a Windows executable out of it I get this error when I run the .exe with the same command line arguments:它在虚拟环境中从 Python 3.9.6 解释器运行良好,但是当我用 pyinstaller(也安装到 venv)将它打包以生成 Windows 可执行文件时,当我运行 .exe 时出现此错误。命令行参数:
Traceback (most recent call last):
File "Mesher.py", line 9, in <module>
ms.load_new_mesh(xyz_file)
pymeshlab.pmeshlab.PyMeshLabException: Unknown format for load: xyz
[24580] Failed to execute script Mesher
Why does pymeshlab recognize my .xyz file fine from Python but not when the same script is wrapped up in a Windows executable?为什么 pymeshlab 可以很好地从 Python 识别我的 .xyz 文件,但在 Windows 可执行文件中包含相同的脚本时却不能识别?
EDIT This also happens when I use a fixed file name for my .xyz file rather than passing it on the command line, or even if I use a .ply file for the input.编辑当我为 .xyz 文件使用固定文件名而不是在命令行上传递它时,或者即使我使用 .ply 文件作为输入,也会发生这种情况。 The .exe version of my script doesn't recognize standard MeshLab file types.
我的脚本的 .exe 版本无法识别标准的 MeshLab 文件类型。
我能够通过使用 cx_Freeze 而不是 pyinstaller 来实现它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.