如何创建一个在 Windows 上使用带有 cx_freeze 的 face_recognition 模块的 python 应用程序?

问题描述

我正在尝试使用 cx_freeze 在 Windows 上构建一个 python 应用程序作为学校项目的一部分,一切运行顺利,直到我真正构建了可执行文件。确实,虽然我在 Pycharm 中启动代码代码运行良好,但我无法让使用 cx_freeze 构建的应用程序运行(虽然我可以构建它)。

这是我用来构建应用程序的文件

import sys
from cx_Freeze import setup,Executable

version = "1.0.0"

base = None

if sys.platform == "win32":
    base = "win32gui"

build_exe_options = {"include_files": ["assets/"],"excludes": ["matplotlib.tests","numpy.random._examples"],"include_msvcr": True}

setup(
    name="Mon Emploi du Temps",version=version,description=f"Mon Emploi du Temps version {version}",options={"build_exe": build_exe_options},executables=[
        Executable(script="main.py",base=base,targetName="Mon Emploi du Temps.exe",shortcutName="Mon Emploi du Temps",shortcutDir="DesktopFolder",icon="assets/logo.ico")]
)

这是我在尝试启动应用程序时收到的错误消息:

运行时错误:无法打开 C:\Users...\build\exe.win-amd64-3.8\lib\face_recognition_models\models\shape_predictor_68_face_landmarks.dat

我在 GitHub 和 StackOverflow 上看到了不同的帖子,但我无法得到我的问题的明确答案,我仍然不明白为什么它不起作用。以下是我阅读的一些主题

RuntimeError: Unable to open shape_predictor_68_face_landmarks.dat?

https://github.com/cmusatyalab/openface/issues/76

How do I fix "RuntimeError: Unable to open shape_predictor_68_face_landmarks.dat" while using google colab?

我什至尝试使用 PyInstaller 构建我的应用程序,但无济于事:

https://github.com/ageitgey/face_recognition/issues/357

考虑到 cmake 和 dlib 模块已正确安装在我的计算机上,我不知道该尝试什么。

提前感谢您抽出时间和您的回答,

保罗

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)