I'm new with python apps. I'm trying to build my python GUI app with pyinstaller. My app depends on the following packages: PyQt4, numpy, pyqtgraph, h5py. I'm working with WinPython-32bit-3.4.4.1.
I build the app with this command:
pyinstaller --hidden-import=h5py.defs --hidden-import=h5py.utils --hidden-import=h5py.h5ac --hidden-import=h5py._proxy VOGE.py
I launch my app with the exe file in the dist directory created by pyinstaller and it seems work fine until the program call numpy and crash with this error:
Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll
The mkl_intel_thread.dll is not present in the software directory; but with the file copied in the root dir of the program I got the same error
Thanks for your help
UPDATE: If you get Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll but you can clearly see that mkl_intel_thread.dll IS IN your program directory, go to numpy/core and literally copy all the files with .dll extensions that you don't have and paste them into your program's directory and re-run.
See Cannot load mkl_intel_thread.dll on python executable, my answer there and its comments. If this still does not solve your problem, try to manually copy other DLLs from the anaconda environment's library path into the app installation directory and its lib subdirectory.
There is still a still a superfluous DLL mkl_rt.dll in lib umpy\core which leads to a missing dependency. I've analyzed a bit further, this DLL gets included as a dependency of numpy\core\_multiarray_umath.cp38-win_amd64.pyd
Our MKL packages are just straight repacks of the intel packages. Sorry, something went wrong. The error message suggests an incompatibility, likely to do with version constraints across channels? Sorry, something went wrong. Once my Windows VM finishes downloading I'll take a look. Has taken about 4 hours so far!
I had the same issue using Pyinstaller and Numpy. By default pyinstaller seems to not take into account numpy binaries so you have to specify it manually. You can add the files editing the ".spec" file "binaries" variable, but that will only work for your current program. If you want it working for all the programs your freeze you should make a "hook" and save it in C:\Python3*\Lib\site-packages\PyInstaller\hooks.
I had to adapt LeonidR's code to make the numpy-hook working. I rewrited it using a more modern, pythonic approach using list comprehensions:
from PyInstaller import log as logging
from PyInstaller import compat
from os import listdir
mkldir = compat.base_prefix + "/Lib/site-packages/numpy/core"
logger = logging.getLogger(__name__)
logger.info("MKL installed as part of numpy, importing that!")
binaries = [(mkldir + "/" + mkl, '') for mkl in listdir(mkldir) if mkl.startswith('mkl_')]
"Binaries" is a list of tuples. The second item of the tuple corresponds to the folder where you want to place the 'dlls'. In this case is empty so it copies them directly in the main folder where your '.exe' is.
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