My wxpython application compiled fine with pyinstaller, until some functionality, based on the from scipy.optimize import leastsq statement was added.
How do I fix this?
First time you run the command pyinstaller myscript.py in the cmd, a myscript.spec file will be created (or you can create it manually).
This file let you specify hidden imports, and I found (by a long and tedious trial-error process) that the following hidden imports did the trick:
'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'
These should probably be linked through hooks, but I could not get my head around how, so this is the "quick&dirty" way.
Now you execute pyinstaller myscript.spec.
My full file looked along these lines:
# -*- 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,
               strip=None,
               upx=True,
               name='myscript')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With