gpt4 book ai didi

python - PyInstaller "failed to execute script"错误

转载 作者:行者123 更新时间:2023-12-02 10:53:25 24 4
gpt4 key购买 nike

我正在尝试使用 PyInstaller 制作一个 exe 文件,但是我无法这样做。该文件已构建并存放在 dist 文件夹中,但是当我尝试运行它时,会弹出错误“无法执行脚本 {name}”。

这是我正在使用的 .spec 文件:

# -*- mode: python ; coding: utf-8 -*-

block_cipher = None


a = Analysis(['simulator.pyw'],
pathex=['C:\\Simulator'],
binaries=[],
datas=[('bin/**/*.kv', './bin/ui'), ('bin/**/*.xml', './bin/ui')],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=True,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='simulator',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False , icon='bin\\ui\\icon.ico')
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='simulator')

这是控制台的输出:

LOG

可能是什么问题呢?

最佳答案

您可以通过命令提示符启动脚本来检查完整的回溯。

这可以通过按 WIN 来完成。 + R和写作cmd然后用 cd command 更改目录直到到达文件夹,然后使用 .\<softwarename>.exe运行。

例如:

> cd C:\softwares\test
> pwd
C:\softwares\test
> .\test.exe

根据经验,这可能是由 ModuleNotFoundError 引起的。 .如果这是问题,您可以将模块名称添加到 hiddenimports在规范中列出。

即: hiddenimports=['pyodbc'],

关于python - PyInstaller "failed to execute script"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57115587/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com