此时我正在使用--debug开关。我能够运行onefile可执行文件,并且可以看到它似乎开始工作了。程序可以找到(sys._MEIPASS)临时目录(按要求打印所需的目录名称),但在从临时目录查找第一个数据文件时报告了“没有这样的文件或目录”的错误。我在.exe上使用了archiveviewer.py,并没有找到需要的数据文件,这似乎是问题所在,但我无法弄清楚原因。构建的数据文件在spec文件描述的目录中。我的完整spec文件如下:
# -*- mode: python -*-
a = Analysis(['develop6.py'],
pathex=['C:\\PYINST20'],
hiddenimports=[],
hookspath=None)
a.datas += [ ('conlist.txt', 'C:\\pyinst20\\conlist.txt', 'DATA'), ('imageblank.gif', 'C:\\pyinst20\\imageblank.gif', 'DATA')]
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name=os.path.join('dist', 'develop6.exe'),
debug=True,
strip=None,
upx=True,
console=True )