无法在python可执行文件上加载mkl_intel_thread.dll [英] Cannot load mkl_intel_thread.dll on python executable
问题描述
我正在尝试创建一个在Windows上运行但不安装python的可执行python程序,为此,我正在使用cx_Freeze.但出现以下错误:无法加载mkl_intel_thread.dll"
I'm trying to create an executable python program that runs on windows without python being installed, for this I'm using cx_Freeze. But I get the following error: "Cannot load mkl_intel_thread.dll"
在安装了python的PC(miniconda3)上,我使用cx_Freeze构建了可执行文件,当我运行该可执行文件时,我还会得到无法加载mkl_intel_thread.dll"的信息.我通过转到python文件夹Library \ bin修复了此问题,并将mkl_intel_thread.dll文件复制到了放置可执行文件的位置.问题是,即使mkl_intel_thread.dll位于文件夹中,当将整个文件夹移至另一台PC(未安装python)时,此错误仍会再次出现.
On my PC, which has python installed (miniconda3), I built the executable using cx_Freeze, and when I ran the executable I also would get "Cannot load mkl_intel_thread.dll". I fixed this by going to my python folder, Library\bin, and copied the mkl_intel_thread.dll file to where the executable is placed. The problem is, when moving the whole folder to another PC (without python installed), this error reappears, even though the mkl_intel_thread.dll is in the folder.
我要分发的文件(plot.py):
File that I want to distribute (plot.py):
import matplotlib.pyplot as plt
a = [0, 1, 2]
b = [0, 2, 0]
plt.fill(a, b, 'b')
plt.show()
cx_Freeze设置文件(setup.py):
cx_Freeze setup file (setup.py):
import cx_Freeze
import sys
import matplotlib
import numpy
import os
os.environ['TCL_LIBRARY'] = "C:\\Miniconda3\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\\Miniconda3\\tcl\\tk8.6"
executables = [cx_Freeze.Executable("plot.py")]
build_exe_options = {"includes":['numpy.core._methods',
'numpy.lib.format', 'matplotlib.backends.backend_tkagg']}
cx_Freeze.setup(
name = "script",
options = {"build_exe": build_exe_options},
version = "0.0",
description = "A basic example",
executables = executables)
推荐答案
-
尝试将在
Library\bin
或numpy\core
下找到的所有以mkl
开头的文件复制到build文件夹以及libiomp5md.dll
中,请参见 cx_freeze转换后的GUI -p(tkinter)在按下plot-Button后崩溃.
Try to copy all files starting with
mkl
you find underLibrary\bin
ornumpy\core
into the build folder, as well aslibiomp5md.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.
一旦找到需要手动复制的文件,就可以使用build_exe
选项的include_files
列表,让cx_Freeze
包括必要的文件(请参阅).下面的代码段).如有必要,可以在include_files
列表中使用元组(source, destination)
作为项目,以使cx_Freeze
将文件从source
复制到特定的destination
到构建目录中,请参见cx_Freeze
文档.
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_Freeze
documentation.
在您发布的问题中的设置脚本中,我还看到了其他潜在问题:
I see further potential problems in the setup script you've posted in your question:
- 使用
build_exe
选项的packages
列表包含整个numpy
软件包,这更容易,也可能更安全 - 动态找出TCL/TK DLL的位置更安全
- 对于
cx_Freeze
5.1.1,TCL/TK DLL必须包含在构建目录的lib
子目录中
- include the whole
numpy
packages using thepackages
list of thebuild_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 alib
subdirectory of the build directory
总而言之,请尝试使用
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.
]}
在您的设置脚本中.
这篇关于无法在python可执行文件上加载mkl_intel_thread.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!