问题
Using PyInstaller 3.3, Python 3.4 I have compiled a program that needs to use the scipy.signal.periodogram() function, and it's causing the .exe to crash the instant it starts up. I've been searching all over stack overflow and other sites for a way to try to include the right DLLs, but to no avail. Please help me figure out if I need to include some specific DLLs in my .spec file or include some other hidden-imports!
Here is my PyInstaller command:
pyinstaller --noupx --hidden-import=tkinter --hidden-import=scipy --hidden-import=matplotlib constantG_constantHz.py
and here is the corresponding error from the command prompt after starting my exe:
Traceback (most recent call last):
File "constantG_constantHz.py", line 16, in
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
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
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
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
And here is my .spec file:
# -*- 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')
回答1:
I have tried the methods before and it did not solve my problem. Finally, I solved it by this way.
When compiling the executables (exe
) files in the command (cmd
) window, my command is written as follows:
pyinstaller -F --paths C:\Users\lixib\Desktop\Hiwi_job\Code\2018.04.23\venv\Lib\site-packages\scipy\extra-dll pdf_num_detect.py
Hope this small tricks can help you all.
回答2:
The issue was lots of missing dlls. PyInstaller has issues finding most of Scipy's dlls, so I had to specify a heck of a lot of them. I'll post my .spec file below in case anyone else wants to see / copy which dlls I had to bring in. Some things might not have been necessary, but it works so I'm not going to mess with it. Make sure that you are pointing to the correct directory for your system though - it won't be the same as mine, so don't just copy/paste :)
# -*- 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 )
来源:https://stackoverflow.com/questions/47065295/pyinstaller-with-scipy-signal-importerror-dll-load-failed