intel mkl python_无法在python可执行文件上加载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"

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.

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 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)

解决方案

EDIT:

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.

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值