解决方法
第一次在cmd中运行命令pyinstaller myscript.py时,将创建一个myscript.spec文件(或者您可以手动创建它).
这个文件允许你指定隐藏的导入,我发现(通过漫长而乏味的试错过程)以下隐藏的导入功能:
这个文件允许你指定隐藏的导入,我发现(通过漫长而乏味的试错过程)以下隐藏的导入功能:
'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.integrate.lsoda'
这些可能应该通过钩子联系起来,但我无法理解如何,所以这是“快速和肮脏”的方式.
现在执行pyinstaller myscript.spec.
我的完整文件看起来如下:
# -*- mode: python -*- a = Analysis(['myscript.py'],pathex=['C:\\SourceCode'],hiddenimports=['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.integrate.lsoda'],hookspath=None,runtime_hooks=None) pyz = PYZ(a.pure) exe = EXE(pyz,a.scripts,exclude_binaries=True,name='myscript.exe',debug=False,strip=None,upx=True,console=True ) coll = COLLECT(exe,a.binaries,a.zipfiles,a.datas,name='myscript')