Python脚本在Spyder中运行,但在打包为Pyinstaller.exe时崩溃(关闭时没有错误消息)

2024-04-20 11:32:44 发布

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

我正在尝试使用Pyinstaller将Python脚本打包为.exe文件。脚本在Spyder中成功运行,但.exe文件在执行过程中突然关闭,没有出现错误消息。我已经找到了.exe关闭的行:

df2['WholesaleCostPerUnit'] = df2.RetailCost/(df2.QuantitySold/df2.Quantity)

df2是一个数据帧。这是我在剧本中第一次把一个熊猫系列分成另一个系列

更新:当df2包含9999个相同的行时.exe运行正常。但是,如果我尝试使用10000行或更多(相同)行运行它,它将在上面的一行关闭,不会出现错误。有了这些信息,我可以构建一个解决方案,但我仍然很想知道为什么会发生这种情况

这是我的规范文件:

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

block_cipher = None


a = Analysis(['cannabis_transaction_sample.py'],
             pathex=['C:\\projects_local\\python_executables\\cannabis_markup_sampling'],
             binaries=[],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name='cannabis_transaction_sample',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=True )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               upx_exclude=[],
               name='cannabis_transaction_sample')

Tags: 文件sample脚本falsetrue错误blockexe