MKL hook trigger an error during setup
donsylvano opened this issue · 3 comments
Problem encountered
During execution of my setup.py, the following error is thrown, after a long list of calls:
File "C:...\miniconda3\envs\testenv\Lib\site-packages\cx_Freeze\hooks\mkl.py", line 29, in load_mkl
if distribution.installer == "pip":
AttributeError: 'NoneType' object has no attribute 'installer'
The fact that disabling the load_mkl function solved the problem indicates that there may be a bug in the mkl hook.
To Reproduce
I created a fresh conda environnement using miniconda.
My script is very short, but it needs pandas, therefore numpy and mkl, as dependecies.
Expected behavior
As far as I understand, the hooks are there to help with importing specific libraries. In this case it seems to add a bug. I found the following workaround for my specific situation:
Workaround
After commenting out the code of the load_mkl function in hooks/mkl.py, the setup is able to create the .exe without any errors, and the resulting program runs successfully.
Desktop
- Windows 10 Entreprise
Conda environnement with: - cx_Freeze 7.1.0 (installed through conda-forge)
- Python 3.11.8
- mkl 2023.1.0
- numpy 1.26.4
- pandas 2.2.1
setup.py
`# -- coding: latin-1 --
from cx_Freeze import setup, Executable
import glob
import os
import sys
import shutil
includes = ['numpy','pandas','mkl']
excludes = []
packages = ['numpy', 'pandas', 'mkl']
bin_excludes = []
include_files=['test.csv']
build_exe_options = {
"optimize": 0,
"includes": includes,
"excludes": excludes,
"packages": packages,
"include_files": include_files,
"bin_excludes": bin_excludes
}
setup(
name="bs_json",
version="1.0",
description = "Read JSON from file",
options = {"build_exe": build_exe_options},
executables = [Executable("bs_json.py", base=None)]
)`
Footnote
This is my first issue report on GitHub. Any constructive feedback welcome
Hi!
Change the line that throws the error:
if distribution.installer == "pip":
by
if distribution and distribution.installer == "pip"
and give a feedback. I should publish the fix soon.
Sometimes the guy just says 'there was an error', and doesn't even include the long traceback. I want to fix it, but without information it's difficult. As for you, you went to the trouble of finding a workaround. That is great.
Hello,
All good! After changing the line as mentioned, no more exception and the setup succeeded.
Thanks for the quick response and for the feedback.
Release 7.1.1 is out!
Documentation