pyinstaller / pyinstaller-hooks-contrib

Community maintained hooks for PyInstaller.
Other
96 stars 126 forks source link

sklearn dropped neighbors._typedef in version 1.0.2 #697

Closed theresaschneids closed 10 months ago

theresaschneids commented 10 months ago

Describe the bug The module sklearn.neighbors._typedef was removed from the sklearn package in 1.0.2 Present in 1.0.1 Removed in 1.0.2

The hidden imports in hook-sklearn.neighbors.py require sklearn.neighbors._typedef for all versions >=0.22, so a warning is thrown

To Reproduce

A minimal example file:

from sklearn.preprocessing import StandardScaler
data = [[0, 0], [0, 0], [1, 1], [1, 1]]
scaler = StandardScaler()
scaler.fit(data)

PyInstaller command:

pyinstaller --clean --onefile test.py

Error:

47783 WARNING: Hidden import "sklearn.neighbors._typedefs" not found!

Expected behavior I expected that, if I added --hidden-import="sklearn.neighbors._typedefs" to my pyinstaller command, that I would no longer receive the warning, but it persisted, leading me to look closer into the cause of the warning. I expected my sklearn version (version 1.3.2) to require sklean.neighbords._typedefs, but I found that it was removed in version 1.0.2.

Screenshots image

Desktop (please complete the following information):

Additional context I propose the solution of editing lines 17-28 of hook-sklearn.neighbors.py as follows


if is_module_satisfies("scikit_learn > 1.0.1"):
    # 1.0.2 and later
    hiddenimports += [
        'sklearn.neighbors._quad_tree',
    ]
elif is_module_satisfies("scikit_learn < 0.22 "):
    # 0.21 and below
    hiddenimports += [
        'sklearn.neighbors.typedefs',
        'sklearn.neighbors.quad_tree',
    ]
else:
    # between and including 0.22 and 1.0.1
    hiddenimports += [
        'sklearn.neighbors._typedefs',
        'sklearn.neighbors._quad_tree',
    ]
bwoodsend commented 10 months ago

Sounds good to me. If you're willing to make that update then go for it.