使用 PyInstaller 3.3、Python 3.4 我编译了一个需要使用 scipy.signal.periodogram() 函数的程序,它导致 .exe 在启动时崩溃。我一直在 stack Overflow 和其他网站上搜索尝试包含正确 DLL 的方法,但没有成功。请帮我弄清楚我是否需要在 .spec 文件中包含一些特定的 DLL 或包含一些其他隐藏导入!
这是我的 PyInstaller 命令:
pyinstaller --noupx --hidden-import=tkinter --hidden-import=scipy --hidden-import=matplotlib constantG_constantHz.py
这是启动我的 exe 后命令提示符中的相应错误:
Traceback (most recent call last):
File "constantG_constantHz.py", line 16, in <module>
File "C:\Users\esandberg\AppData\Local\Continuum\anaconda3\envs\py34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\signal\__init__.py", line 304, in <module>
File "C:\Users\esandberg\AppData\Local\Continuum\anaconda3\envs\py34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\signal\bsplines.py", line 12, in <module>
File "C:\Users\esandberg\AppData\Local\Continuum\anaconda3\envs\py34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\scipy\special\__init__.py", line 640, in <module>
File "C:\Users\esandberg\AppData\Local\Continuum\anaconda3\envs\py34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 714, in load_module
module = loader.load_module(fullname)
ImportError: DLL load failed: The specified module could not be found.
[1272] Failed to execute script 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')