mljar / mljar-supervised

Python package for AutoML on Tabular Data with Feature Engineering, Hyper-Parameters Tuning, Explanations and Automatic Documentation
https://mljar.com
MIT License
3.06k stars 409 forks source link

AutoML import fails due to dependency ImportError: cannot import name 'Concatenate' from 'typing_extensions' #618

Open xekl opened 1 year ago

xekl commented 1 year ago

I installed pip install mljar-supervised and manually fixed a dependency conflict with numba and the numpy version, but when I try from supervised.automl import AutoML, it does not work due to an ImportError way down the dependencies.

The complete traceback:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-13-1488fde12bbc> in <module>
----> 1 from supervised.automl import AutoML # mljar

~/.local/lib/python3.9/site-packages/supervised/__init__.py in <module>
      1 __version__ = "0.11.5"
      2 
----> 3 from supervised.automl import AutoML

~/.local/lib/python3.9/site-packages/supervised/automl.py in <module>
      1 import logging
----> 2 from supervised.base_automl import BaseAutoML
      3 from supervised.utils.config import LOG_LEVEL
      4 
      5 # libraries for type hints

~/.local/lib/python3.9/site-packages/supervised/base_automl.py in <module>
     27 from supervised.callbacks.learner_time_constraint import LearnerTimeConstraint
     28 from supervised.callbacks.total_time_constraint import TotalTimeConstraint
---> 29 from supervised.ensemble import Ensemble
     30 from supervised.exceptions import AutoMLException
     31 from supervised.exceptions import NotTrainedException

~/.local/lib/python3.9/site-packages/supervised/ensemble.py in <module>
     12 from supervised.algorithms.registry import BINARY_CLASSIFICATION
     13 from supervised.algorithms.registry import MULTICLASS_CLASSIFICATION
---> 14 from supervised.model_framework import ModelFramework
     15 from supervised.utils.metric import Metric
     16 from supervised.utils.config import LOG_LEVEL

~/.local/lib/python3.9/site-packages/supervised/model_framework.py in <module>
     34 from supervised.utils.learning_curves import LearningCurves
     35 
---> 36 import optuna
     37 import joblib
     38 

~/.local/lib/python3.9/site-packages/optuna/__init__.py in <module>
      3 from optuna import integration
      4 from optuna import logging
----> 5 from optuna import multi_objective
      6 from optuna import pruners
      7 from optuna import samplers

~/.local/lib/python3.9/site-packages/optuna/multi_objective/__init__.py in <module>
      1 from optuna._imports import _LazyImport
----> 2 from optuna.multi_objective import samplers
      3 from optuna.multi_objective import study
      4 from optuna.multi_objective import trial
      5 from optuna.multi_objective.study import create_study

~/.local/lib/python3.9/site-packages/optuna/multi_objective/samplers/__init__.py in <module>
----> 1 from optuna.multi_objective.samplers._adapter import _MultiObjectiveSamplerAdapter
      2 from optuna.multi_objective.samplers._base import BaseMultiObjectiveSampler
      3 from optuna.multi_objective.samplers._motpe import MOTPEMultiObjectiveSampler
      4 from optuna.multi_objective.samplers._nsga2 import NSGAIIMultiObjectiveSampler
      5 from optuna.multi_objective.samplers._random import RandomMultiObjectiveSampler

~/.local/lib/python3.9/site-packages/optuna/multi_objective/samplers/_adapter.py in <module>
      4 from optuna import multi_objective
      5 from optuna.distributions import BaseDistribution
----> 6 from optuna.samplers import BaseSampler
      7 from optuna.study import Study
      8 from optuna.trial import FrozenTrial

~/.local/lib/python3.9/site-packages/optuna/samplers/__init__.py in <module>
----> 1 from optuna.samplers import nsgaii
      2 from optuna.samplers._base import BaseSampler
      3 from optuna.samplers._brute_force import BruteForceSampler
      4 from optuna.samplers._cmaes import CmaEsSampler
      5 from optuna.samplers._grid import GridSampler

~/.local/lib/python3.9/site-packages/optuna/samplers/nsgaii/__init__.py in <module>
----> 1 from optuna.samplers.nsgaii._crossovers._base import BaseCrossover
      2 from optuna.samplers.nsgaii._crossovers._blxalpha import BLXAlphaCrossover
      3 from optuna.samplers.nsgaii._crossovers._sbx import SBXCrossover
      4 from optuna.samplers.nsgaii._crossovers._spx import SPXCrossover
      5 from optuna.samplers.nsgaii._crossovers._undx import UNDXCrossover

~/.local/lib/python3.9/site-packages/optuna/samplers/nsgaii/_crossovers/_base.py in <module>
      3 import numpy as np
      4 
----> 5 from optuna.study import Study
      6 
      7 

~/.local/lib/python3.9/site-packages/optuna/study/__init__.py in <module>
      2 from optuna.study._study_direction import StudyDirection
      3 from optuna.study._study_summary import StudySummary
----> 4 from optuna.study.study import copy_study
      5 from optuna.study.study import create_study
      6 from optuna.study.study import delete_study

~/.local/lib/python3.9/site-packages/optuna/study/study.py in <module>
     23 from optuna import pruners
     24 from optuna import samplers
---> 25 from optuna import storages
     26 from optuna import trial as trial_module
     27 from optuna._convert_positional_args import convert_positional_args

~/.local/lib/python3.9/site-packages/optuna/storages/__init__.py in <module>
      3 from optuna._callbacks import RetryFailedTrialCallback
      4 from optuna.storages._base import BaseStorage
----> 5 from optuna.storages._cached_storage import _CachedStorage
      6 from optuna.storages._heartbeat import fail_stale_trials
      7 from optuna.storages._in_memory import InMemoryStorage

~/.local/lib/python3.9/site-packages/optuna/storages/_cached_storage.py in <module>
     16 from optuna.storages import BaseStorage
     17 from optuna.storages._heartbeat import BaseHeartbeat
---> 18 from optuna.storages._rdb.storage import RDBStorage
     19 from optuna.study._frozen import FrozenStudy
     20 from optuna.study._study_direction import StudyDirection

~/.local/lib/python3.9/site-packages/optuna/storages/_rdb/storage.py in <module>
     25 from optuna.storages._base import DEFAULT_STUDY_NAME_PREFIX
     26 from optuna.storages._heartbeat import BaseHeartbeat
---> 27 from optuna.storages._rdb.models import TrialValueModel
     28 from optuna.study._frozen import FrozenStudy
     29 from optuna.study._study_direction import StudyDirection

~/.local/lib/python3.9/site-packages/optuna/storages/_rdb/models.py in <module>
      6 from typing import Tuple
      7 
----> 8 from sqlalchemy import asc
      9 from sqlalchemy import case
     10 from sqlalchemy import CheckConstraint

~/.local/lib/python3.9/site-packages/sqlalchemy/__init__.py in <module>
     10 from typing import Any
     11 
---> 12 from . import util as _util
     13 from .engine import AdaptedConnection as AdaptedConnection
     14 from .engine import BaseRow as BaseRow

~/.local/lib/python3.9/site-packages/sqlalchemy/util/__init__.py in <module>
     13 
     14 from . import preloaded as preloaded
---> 15 from ._collections import coerce_generator_arg as coerce_generator_arg
     16 from ._collections import coerce_to_immutabledict as coerce_to_immutabledict
     17 from ._collections import column_dict as column_dict

~/.local/lib/python3.9/site-packages/sqlalchemy/util/_collections.py in <module>
     37 
     38 from ._has_cy import HAS_CYEXTENSION
---> 39 from .typing import Literal
     40 from .typing import Protocol
     41 

~/.local/lib/python3.9/site-packages/sqlalchemy/util/typing.py in <module>
     35 if True:  # zimports removes the tailing comments
     36     from typing_extensions import Annotated as Annotated  # 3.8
---> 37     from typing_extensions import Concatenate as Concatenate  # 3.10
     38     from typing_extensions import (
     39         dataclass_transform as dataclass_transform,  # 3.11,

ImportError: cannot import name 'Concatenate' from 'typing_extensions' (/home/myusername/.local/lib/python3.9/site-packages/typing_extensions.py)
xekl commented 1 year ago

I fixed the problem with a simple `pip install --upgrade typing-extensions' (plus a restart of the kernel for the changes to take effect). However, this took me a while to solve, even debating a python version update, and I did not find it in the issues, yet, so I decided to post.

pplonski commented 1 year ago

Thank you @xekl for postintg the solution!