RuntimeError: Failed to import transformers.pipelines because of the following error : cannot import name 'Memory' from 'joblib' (unknown location)
Author: tasmiatasrin
Pull request: no

### System Info

Hello, 

I installed transformers from the conda channel huggingface in linux. The Transformers version installed: "4.32.1". FYI, Python version: 3.9.15, Conda version: 4.10.3, Conda build version:3.21.5 . 



### Who can help?

I tried to check whether the installation is working by running the python command given in the huggingface transformers installation page, I am getting the following error: 

Traceback (most recent call last):
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/transformers/utils/import_utils.py", line 1130, in _get_module
    return importlib.import_module("." + module_name, self.__name__)
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/transformers/pipelines/__init__.py", line 60, in <module>
    from .document_question_answering import DocumentQuestionAnsweringPipeline
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/transformers/pipelines/document_question_answering.py", line 29, in <module>
    from .question_answering import select_starts_ends
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/transformers/pipelines/question_answering.py", line 9, in <module>
    from ..data import SquadExample, SquadFeatures, squad_convert_examples_to_features
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/transformers/data/__init__.py", line 26, in <module>
    from .metrics import glue_compute_metrics, xnli_compute_metrics
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/transformers/data/metrics/__init__.py", line 20, in <module>
    from sklearn.metrics import f1_score, matthews_corrcoef
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/sklearn/__init__.py", line 83, in <module>
    from .base import clone
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/sklearn/base.py", line 19, in <module>
    from .utils import _IS_32BIT
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/sklearn/utils/__init__.py", line 19, in <module>
    from . import _joblib, metadata_routing
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/sklearn/utils/_joblib.py", line 8, in <module>
    from joblib import (
ImportError: cannot import name 'Memory' from 'joblib' (unknown location)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 1055, in _handle_fromlist
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/transformers/utils/import_utils.py", line 1120, in __getattr__
    module = self._get_module(self._class_to_module[name])
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/transformers/utils/import_utils.py", line 1132, in _get_module
    raise RuntimeError(
RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
cannot import name 'Memory' from 'joblib' (unknown location)

Also, getting the same error for importing transformers.trainer while using image pretraining from https://github.com/huggingface/transformers/tree/main/examples/pytorch/image-pretraining. 

Is it any issue related to my installation? how to fix this? any help would be truly appreciated. 



### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [X] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

While trying to run this following code from: 

https://github.com/huggingface/transformers/blob/main/examples/pytorch/image-pretraining/run_mim.py

I am going to use my own datasets with images.  

### Expected behavior

Traceback (most recent call last):
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/transformers/utils/import_utils.py", line 1130, in _get_module
    return importlib.import_module("." + module_name, self.__name__)
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/transformers/trainer.py", line 59, in <module>
    from .data.data_collator import DataCollator, DataCollatorWithPadding, default_data_collator
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/transformers/data/__init__.py", line 26, in <module>
    from .metrics import glue_compute_metrics, xnli_compute_metrics
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/transformers/data/metrics/__init__.py", line 20, in <module>
    from sklearn.metrics import f1_score, matthews_corrcoef
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/sklearn/__init__.py", line 83, in <module>
    from .base import clone
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/sklearn/base.py", line 19, in <module>
    from .utils import _IS_32BIT
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/sklearn/utils/__init__.py", line 19, in <module>
    from . import _joblib, metadata_routing
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/sklearn/utils/_joblib.py", line 8, in <module>
    from joblib import (
ImportError: cannot import name 'Memory' from 'joblib' (unknown location)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/tasmia/minigrid_agent/Minigrid-master/minigrid_img_trainer/run_mim.py", line 29, in <module>
    from transformers import (
  File "<frozen importlib._bootstrap>", line 1055, in _handle_fromlist
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/transformers/utils/import_utils.py", line 1120, in __getattr__
    module = self._get_module(self._class_to_module[name])
  File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/transformers/utils/import_utils.py", line 1132, in _get_module
    raise RuntimeError(
RuntimeError: Failed to import transformers.trainer because of the following error (look up to see its traceback):
cannot import name 'Memory' from 'joblib' (unknown location)

Comments:
Related comment on another issue: https://github.com/huggingface/transformers/issues/14773#issuecomment-1787714316

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.