使用pyinstaller 打包.py文件   pyinstaller -F summary.py

生成exe报错

这个问题出现的原因是,有些模块是隐藏导入的,但是pyinstaller打包时并未指定,所以执行时找不到此模块

解决方法是 在打包语句后加上

pyinstaller -F G:\workspace\summary\summary.py --hidden-import scipy._lib.messagestream
然后再打包,再报错

循环多次后,最终语句变成

pyinstaller -F G:\workspace\summary\summary.py --hidden-import scipy._lib.messagestream --hidden-import sklearn.neighbors.typedefs --hidden-import sklearn.neighbors.quad_tree --hidden-import sklearn.tree._criterion --hidden-import sklearn.tree._utils
exe运行成功
另外可以在summary.spec文件中修改hiddenimports

# -*- mode: python -*-

block_cipher = None


a = Analysis(['G:\\workspace\\summary\\summary.py'],
pathex=['C:\\Users\\Administrator'],
binaries=[],
datas=[],
hiddenimports=['scipy._lib.messagestream', 'sklearn.neighbors.typedefs', 'sklearn.neighbors.quad_tree', 'sklearn.tree._criterion', 'sklearn.tree._utils'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='summary',
debug=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=True )

posted on 2018-11-08 09:59  沙沙沙啊啊皮  阅读(409)  评论(0编辑  收藏  举报