Cannot load mkl_intel_thread.dll on python executable

EDIT:

  1. Try to copy all files starting with mkl you find under Library\bin or numpy\core into the build folder, as well as libiomp5md.dll, see Python Pyinstaller 3.1 Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll and cx_freeze converted GUI-app (tkinter) crashes after pressing plot-Button.

    Once you have found out which file(s) need(s) to be manually copied, you can let cx_Freeze include the necessary file(s) by using the include_files list of the build_exe options (see code snippet below). If necessary, you can use a tuple (source, destination) as item in the include_files list to let cx_Freeze copy a file from source to a specific destination into the build directory, see the cx_Freezedocumentation.

  2. I see further potential problems in the setup script you've posted in your question:

    • include the whole numpy packages using the packages list of the build_exe options, it is easier and maybe safer
    • it is safer to dynamically find out the location of the TCL/TK DLLs
    • for cx_Freeze 5.1.1, the TCL/TK DLLs need to be included in a lib subdirectory of the build directory

In summary, try t o use

PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')

build_exe_options = {'packages': ['numpy'],
                     'includes': ['matplotlib.backends.backend_tkagg'],
                     'include_files': [(os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll'),
                                        os.path.join('lib', 'tcl86t.dll')),
                                       (os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
                                        os.path.join('lib', 'tk86t.dll'))
                                       # add here further files which need to be included as described in 1.
                                      ]}

in your setup script.