Search code examples
pythonwindowscx-freeze

cx_Freeze unable fo find mkl: MKL FATAL ERROR: Cannot load mkl_intel_thread.dll


I am struggling trying to generate a python executable on Windows 10. I have already tried the solution proposed in Cannot load mkl_intel_thread.dll on python executable and many variations, but still getting the error.

My setup.py:

from cx_Freeze import setup, Executable

additional_mods = ["numpy", "pandas", "spacy"]
# Dependencies are automatically detected, but it might need
# fine tuning.
# buildOptions = dict(packages=[], excludes=[], includes=additional_mods)
buildOptions = dict(packages=additional_mods, excludes=[])

base = "Console"

executables = [Executable("app.py", base=base)]


setup(
    name="bpo",
    version="1.0",
    description="",
    options=dict(build_exe=buildOptions),
    executables=executables,
)

What could be happening? mkl is installed and I have copied its content to the lib path as the answer proposed.

I have also tried to set all these variables to 1, as specified in Troubleshooting section of the anaconda docs without luck:

    CONDA_DLL_SEARCH_MODIFICATION_ENABLE
    CONDA_DLL_SEARCH_MODIFICATION_DEBUG
    CONDA_DLL_SEARCH_MODIFICATION_NEVER_ADD_WINDOWS_DIRECTORY
    CONDA_DLL_SEARCH_MODIFICATION_NEVER_ADD_CWD

Solution

  • Try to copy the mkl_* dependencies to the build directory itself instead of the build/lib.

    You can let cx_Freeze include the necessary file(s) by using the include_files list of the build_exe options.