mne-python icon indicating copy to clipboard operation
mne-python copied to clipboard

need to specify min version of scikit-learn

Open drammock opened this issue 10 months ago • 3 comments

ImportError: cannot import name 'validate_data' from 'sklearn.utils.validation'

this happens with sklearn 1.4.1post1. full traceback:

Traceback (most recent call last):
  File "/opt/conda/miniforge3/envs/badbaby/bin/mne_bids_pipeline", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/mne-bids-pipeline/mne_bids_pipeline/_main.py", line 188, in main
    STEP_MODULES = _get_step_modules()
                   ^^^^^^^^^^^^^^^^^^^
  File "/opt/mne-bids-pipeline/mne_bids_pipeline/_config_utils.py", line 716, in _get_step_modules
    from .steps import freesurfer, init, preprocessing, sensor, source
  File "/opt/mne-bids-pipeline/mne_bids_pipeline/steps/sensor/__init__.py", line 3, in <module>
    from . import (
  File "/opt/mne-bids-pipeline/mne_bids_pipeline/steps/sensor/_02_decoding_full_epochs.py", line 17, in <module>
    from mne.decoding import Vectorizer
  File "/opt/conda/miniforge3/envs/badbaby/lib/python3.12/site-packages/lazy_loader/__init__.py", line 77, in __getattr__
    submod = importlib.import_module(submod_path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/miniforge3/envs/badbaby/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mne-python/mne/decoding/transformer.py", line 9, in <module>
    from sklearn.utils.validation import check_is_fitted, validate_data
ImportError: cannot import name 'validate_data' from 'sklearn.utils.validation' (/opt/conda/miniforge3/envs/badbaby/lib/python3.12/site-packages/sklearn/utils/validation.py)

drammock avatar Mar 03 '25 17:03 drammock

Ugggghhhh this is really (also) a MNE-Python bug because we don't specify one here

https://github.com/mne-tools/mne-python/blob/2587cda68e3f1795a8aa1c05084bf503ad91078c/pyproject.toml#L123

and 1.4.0 is only 1 year old, we should support up to 2 years back. I'll transfer the issue

larsoner avatar Mar 03 '25 17:03 larsoner

this is really (also) a MNE-Python bug because we don't specify one

yep I had just realized that and was about to migrate the issue

drammock avatar Mar 03 '25 17:03 drammock

origin is #13065 which is not yet in a released version, which is good at least. Only affects MNE-python dev.

drammock avatar Mar 03 '25 17:03 drammock