Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MKL hook trigger an error during setup #2449

Closed
donsylvano opened this issue Jun 11, 2024 · 3 comments · Fixed by #2452
Closed

MKL hook trigger an error during setup #2449

donsylvano opened this issue Jun 11, 2024 · 3 comments · Fixed by #2452

Comments

@donsylvano
Copy link

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

@marcelotduarte
Copy link
Owner

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.

@donsylvano
Copy link
Author

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.

@marcelotduarte
Copy link
Owner

Release 7.1.1 is out!
Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants