使用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后命令提示符中的相应错误:
追踪(最近一次呼叫最后一次):
文件" constantG_constantHz.py",第16行,
文件" C:\ Users \ esandberg \ AppData \ Local \ Continuum \ anaconda3 \ envs \ py34 \ lib \ site-packages \ PyInstaller \ loader \ pyimod03_importers.py",第631行,在exec_module中 exec(字节码,模块。字典)
文件" site-packages \ scipy \ signal__init __。py",第304行,
文件" C:\ Users \ esandberg \ AppData \ Local \ Continuum \ anaconda3 \ envs \ py34 \ lib \ site-packages \ PyInstaller \ loader \ pyimod03_importers.py",第631行,在exec_module中 exec(字节码,模块。字典)
文件" site-packages \ scipy \ signal \ bsplines.py",第12行,
文件" C:\ Users \ esandberg \ AppData \ Local \ Continuum \ anaconda3 \ envs \ py34 \ lib \ site-packages \ PyInstaller \ loader \ pyimod03_importers.py",第631行,在exec_module中 exec(字节码,模块。字典)
文件" site-packages \ scipy \ special__init __。py",第640行,
文件" C:\ Users \ esandberg \ AppData \ Local \ Continuum \ anaconda3 \ envs \ py34 \ lib \ site-packages \ PyInstaller \ loader \ pyimod03_importers.py",第714行,在load_module中 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')
答案 0 :(得分:3)
我之前尝试过这些方法并没有解决我的问题。最后,我通过这种方式解决了它。
在命令(exe
)窗口中编译可执行文件(cmd
)时,我的命令编写如下:
pyinstaller -F --paths C:\Users\lixib\Desktop\Hiwi_job\Code\2018.04.23\venv\Lib\site-packages\scipy\extra-dll pdf_num_detect.py
希望这些小技巧可以帮助你们所有人。
答案 1 :(得分:1)
问题是很多漏洞。 PyInstaller在查找大部分Scipy的dll时遇到了问题,所以我不得不指定其中很多。我会在下面发布我的.spec文件以防其他人想要查看/复制我必须带来的dll。有些事情可能没有必要,但它确实有效,所以我不会惹它。确保您指向系统的正确目录 - 它与我的不同,所以不要只复制/粘贴:)
# -*- mode: python -*-
block_cipher = None
mkl_dlls = [('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_avx.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_avx2.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_avx512.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_core.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_def.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_intel_thread.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_mc.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_mc3.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_rt.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_sequential.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_tbb_thread.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_vml_avx.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_vml_avx2.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_vml_avx512.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_vml_cmpt.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_vml_def.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_vml_mc.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_vml_mc2.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\mkl_vml_mc3.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\numpy\\core\\libiomp5md.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libansari.R6EA3HQP5KZ6TAXU4Y4ZVTRPT7UVA53Z.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libbanded5x.WZIUXDGQF4EXGFMCS2HGNLMUYHBRQUUF.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libbispeu.5N2XSD7URZS4WTOSLTOG4DDMA4HGB46U.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libblkdta00.LJOUU3SAGG47ULUG76DDJIAQ3SJZPC3K.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libchkder.6HLXPVTQJEGRZGLI5DFRMNW3SS76BHP6.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libcobyla2.JEGTSUUFJ7DFXWZN5PAYZTTLBDATC4WD.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libdcosqb.K4J3XBR4PEETMRHZICUWW4LXG5UONZ34.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libdcosqb.QRGA36MB6CFHWLQN6ETWARR4M4E6P3C2.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libdcsrch.I2AOPDCXAPDRFNPWY55H5UE7XZSU5CVN.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libdet.6GZFPKJ7BNDGVB7LFKBA6Z6U3VHYDRNY.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libdfft_sub.U4F67CR5EXPQGGTDKQXO4Q644NUQ3EQ6.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libdfitpack.2Y4SCYSHMU4DXJIF3BLBGBCDGFPGNXB5.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libdgamln.VNYWJHKRIIPRROV3CUDLW473BST7CGWP.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libdop853.6TJTQZW3I3Q3QIDQHEOBEZKJ3NYRXI4B.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libdqag.62LLADARAQRQLGIRWJXRQ7DKBCHYVFM7.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libd_odr.QDWMEQYLAGCKZEYTV3WWPRP5CLZ3G4WQ.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\liblbfgsb.T5BNFBSTQTIIF6ISVJFBJAWBU7OKBGPL.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libmvndst.LY22DRRGFBEFI34ZKZWNM3LQKXRWY2M2.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libnnls.5LTQOLAJY5PFO6MOEXWNMRWVFRWHYHKT.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libopenblas.BNVRK7633HSX7YVO2TADGR4A5KEKXJAW.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libslsqp_op.NNY57ZXZ43A4RH3YWFA7BKHP5PC2K3I5.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libspecfun.PT6DS3HUOGYNSXUO4OUKK6ATA7B5KP2K.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libSTOPTEST.ULMD4CATLBJOTE3KABHKOG56HAQIX5F6.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libvode.XW5WVKKTDJOOC5XUHCVKZ4AYR2TXGRF4.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libwrap_dum.G2F2CGV7KURTEF5GFBNVGKVM6FV5JBCV.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\libwrap_dum.XGSO5H22J6VUAWYNCLIXCV2EJ754HJMI.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\lib_arpack-.BSIUF6E2Z6VKRD6SNEY37WASTOLCKTAP.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\lib_blas_su.C3OGRVVRISPWLMOVEY4KXYSPKJEZ7QG6.gfortran-win_amd64.dll', '.'),
('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\envs\\py34\\Lib\\site-packages\\scipy\\extra-dll\\lib_test_fo.JF5HTWMUPBXWGAYEBVEJU3OZAHTSVKCT.gfortran-win_amd64.dll', '.')]
a = Analysis(['constantG_constantHz.py'],
pathex=['C:\\Users\\esandberg\\Desktop'],
binaries=mkl_dlls,
datas=[('C:\\Users\\erik\\AppData\\Local\\Continuum\\anaconda3\\Lib\\site-packages\\scipy\\special\\_ufuncs_cxx.cp36-win_amd64.pyd','.'),],
hiddenimports=['scipy._lib.messagestream', 'numpy', 'tkinter', 'scipy', 'matplotlib', 'fixtk', 'scipy.signal', 'scipy.signal.bsplines', 'scipy.special', 'scipy.special._ufuncs_cxx',
'scipy.linalg.cython_blas',
'scipy.linalg.cython_lapack',
'scipy.integrate',
'scipy.integrate.quadrature',
'scipy.integrate.odepack',
'scipy.integrate._odepack',
'scipy.integrate.quadpack',
'scipy.integrate._quadpack',
'scipy.integrate._ode',
'scipy.integrate.vode',
'scipy.integrate._dop', 'scipy._lib', 'scipy._build_utils','scipy.__config__',
'scipy.integrate.lsoda', 'scipy.cluster', 'scipy.constants','scipy.fftpack','scipy.interpolate','scipy.io','scipy.linalg','scipy.misc','scipy.ndimage','scipy.odr','scipy.optimize','scipy.setup','scipy.sparse','scipy.spatial','scipy.special','scipy.stats','scipy.version'],
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='constantG_constantHz',
debug=False,
strip=False,
upx=False,
runtime_tmpdir=None,
console=True )