pyinstaller生成的exe文件在执行时出现问题

2024-10-01 11:23:07 发布

您现在位置:Python中文网/ 问答频道 /正文

下面是python脚本:

enter image description here

我使用Visual Studio代码使用以下命令运行文件:

enter image description here

我得到了想要的结果:

enter image description here

现在,我试图通过打开文件夹中的PowerShell来创建.exe文件,该文件夹是我的脚本和 运行下一行:

enter image description here

以下是我得到的资料(不包括otherScripts文件夹):

enter image description here

现在,我打开CMD,导航到所需的文件夹,并使用下面几行代码运行.exe文件:

enter image description here

以下是我得到的第一个警告:

enter image description here

这是我得到的回溯(控制台立即关闭,我无法使用剪切工具捕获错误,因此我通过C#Win表单应用程序运行它,并将标准错误重定向到表单中的标签):

enter image description here

我试过:

  1. pip安装变压器-美国
  2. 使用命令--onedir代替--onefile
  3. 脚本中的第3行(导入TQM)最近被添加以尝试修复错误。因为它说“没有找到TQM,并且是应用程序所需要的。”,所以我把它放在那里
  4. 将pyinstaller和transformers更新至最新版本
  5. 其他我现在不记得的事情

这些东西都不管用。我被困在这里了。 我真的非常感谢任何帮助来解决这个问题


Tags: 文件代码命令脚本文件夹cmd表单错误
2条回答

对我来说,将“tqdm目录”添加到数据解决了问题:)

脚本中规范:

datas=[
('C:\\<...>\\Lib\\site-packages\\tqdm', 'tqdm\\'),
('C:\\<...>\\Lib\\site-packages\\tqdm-4.50.2.dist-info', 'tqdm-4.50.2.dist-info\\'),
...],

尝试使用 exclude-module=torch构建(取自:https://github.com/pyinstaller/pyinstaller/issues/4695

相关问题 更多 >