使用PyInstaller 3.3,Python 3.4我编译了一个需要使用scipy.signal.periodogram()函数的程序,它导致.exe在它启动的瞬间崩溃 . 我一直在搜索堆栈溢出和其他网站,试图包含正确的DLL,但无济于事 . 请帮我弄清楚我是否需要在我的.spec文件中包含一些特定的DLL或包含一些其他的隐藏导入!
这是我的PyInstaller命令:
pyinstaller --noupx --hidden-import=tkinter --hidden-import=scipy --hidden-import=matplotlib constantG_constantHz.py
这是启动我的exe后命令提示符中的相应错误:
Traceback(最近一次调用最后一次):
文件“constantG_constantHz.py”,第16行,in
文件"C:\Users\esandberg\AppData\Local\Continuum\anaconda3\envs\py34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py",第631行,在exec_module exec中(字节码,模块. dict )
文件“site-packages \ scipy \ signal__init __ . py”,第304行,in
文件"C:\Users\esandberg\AppData\Local\Continuum\anaconda3\envs\py34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py",第631行,在exec_module exec中(字节码,模块. dict )
文件“site-packages \ scipy \ signal \ bsplines.py”,第12行,in
文件"C:\Users\esandberg\AppData\Local\Continuum\anaconda3\envs\py34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py",第631行,在exec_module exec中(字节码,模块. dict )
文件“site-packages \ scipy \ special__init __ . py”,第640行,in
文件“C:\ Users \ esandberg \ AppData \ Local \ Continuum \ anaconda3 \ envs \ py34 \ lib \ site-packages \ PyInstaller \ loader \ pyimod03_importers.py”,第714行,在load_module模块中= loader.load_module(fullname)
ImportError:DLL加载失败:找不到指定的模块 .
[1272]无法执行脚本constantG_constantHz
这是我的.spec文件:
# -*- mode: python -*-
block_cipher = None
a = Analysis(['constantG_constantHz.py'],
pathex=['C:\\Users\\esandberg\\Desktop'],
binaries=[],
datas=[],
hiddenimports=['tkinter', 'scipy', 'matplotlib'],
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,
exclude_binaries=True,
name='constantG_constantHz',
debug=False,
strip=False,
upx=False,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
name='constantG_constantHz')
2 回答
我之前尝试过这些方法并没有解决我的问题 . 最后,我通过这种方式解决了它 .
在命令(
cmd
)窗口中编译可执行文件(exe
)文件时,我的命令编写如下:希望这个小技巧可以帮助你们所有人 .
问题是很多漏洞 . PyInstaller在查找大部分Scipy的dll时遇到了问题,所以我不得不指定其中很多 . 我会在下面发布我的.spec文件以防其他人想要查看/复制我必须带来的dll . 有些事情可能没有必要,但它确实有效,所以我不会惹它 . 确保您指向系统的正确目录 - 它与我的不同,所以不要只复制/粘贴:)