RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback): cannot import name '_rename_parameter' from 'scipy._lib._util' (/databricks/python/lib/python3.8/site-packages/scipy/_lib/_util.py)
## Environment info
transformers version: '4.26.1'
Platform: Databricks

the command to import, return the error below
```
from transformers import pipeline
```

```
RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
cannot import name '_rename_parameter' from 'scipy._lib._util' (/databricks/python/lib/python3.8/site-packages/scipy/_lib/_util.py)
```
## Who can help
@Narsil

full trace of error
```
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/databricks/python/lib/python3.8/site-packages/transformers/utils/import_utils.py in _get_module(self, module_name)
   1109         try:
-> 1110             return importlib.import_module("." + module_name, self.__name__)
   1111         except Exception as e:

/usr/lib/python3.8/importlib/__init__.py in import_module(name, package)
    126             level += 1
--> 127     return _bootstrap._gcd_import(name[level:], package, level)
    128 

/usr/lib/python3.8/importlib/_bootstrap.py in _gcd_import(name, package, level)

/usr/lib/python3.8/importlib/_bootstrap.py in _find_and_load(name, import_)

/usr/lib/python3.8/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)

/usr/lib/python3.8/importlib/_bootstrap.py in _load_unlocked(spec)

/usr/lib/python3.8/importlib/_bootstrap_external.py in exec_module(self, module)

/usr/lib/python3.8/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

/databricks/python/lib/python3.8/site-packages/transformers/pipelines/__init__.py in <module>
     64 from .depth_estimation import DepthEstimationPipeline
---> 65 from .document_question_answering import DocumentQuestionAnsweringPipeline
     66 from .feature_extraction import FeatureExtractionPipeline

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    161             # look at preceding stack frames for relevant error information.
--> 162             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    163 

/databricks/python/lib/python3.8/site-packages/transformers/pipelines/document_question_answering.py in <module>
     28 from .base import PIPELINE_INIT_ARGS, ChunkPipeline
---> 29 from .question_answering import select_starts_ends
     30 

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    161             # look at preceding stack frames for relevant error information.
--> 162             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    163 

/databricks/python/lib/python3.8/site-packages/transformers/pipelines/question_answering.py in <module>
      7 
----> 8 from ..data import SquadExample, SquadFeatures, squad_convert_examples_to_features
      9 from ..modelcard import ModelCard

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    161             # look at preceding stack frames for relevant error information.
--> 162             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    163 

/databricks/python/lib/python3.8/site-packages/transformers/data/__init__.py in <module>
     29 )
---> 30 from .metrics import glue_compute_metrics, xnli_compute_metrics
     31 from .processors import (

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    161             # look at preceding stack frames for relevant error information.
--> 162             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    163 

/databricks/python/lib/python3.8/site-packages/transformers/data/metrics/__init__.py in <module>
     21 
---> 22 if is_sklearn_available():
     23     from sklearn.metrics import f1_score, matthews_corrcoef

/databricks/python/lib/python3.8/site-packages/transformers/utils/import_utils.py in is_sklearn_available()
    563         return False
--> 564     return is_scipy_available() and importlib.util.find_spec("sklearn.metrics")
    565 

/usr/lib/python3.8/importlib/util.py in find_spec(name, package)
     93         if parent_name:
---> 94             parent = __import__(parent_name, fromlist=['__path__'])
     95             try:

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    161             # look at preceding stack frames for relevant error information.
--> 162             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    163 

/databricks/python/lib/python3.8/site-packages/mlflow/utils/import_hooks/__init__.py in load_module(self, fullname)
    234         try:
--> 235             module = self.loader.load_module(fullname)
    236             notify_module_loaded(module)

/databricks/python_shell/dbruntime/PostImportHook.py in load_module(self, fullname)
    215         try:
--> 216             module = self.loader.load_module(fullname)
    217             notify_module_loaded(module)

/databricks/python/lib/python3.8/site-packages/sklearn/__init__.py in <module>
     81     from . import __check_build  # noqa: F401
---> 82     from .base import clone
     83     from .utils._show_versions import show_versions

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    161             # look at preceding stack frames for relevant error information.
--> 162             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    163 

/databricks/python/lib/python3.8/site-packages/sklearn/base.py in <module>
     16 from ._config import get_config
---> 17 from .utils import _IS_32BIT
     18 from .utils._tags import (

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    161             # look at preceding stack frames for relevant error information.
--> 162             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    163 

/databricks/python/lib/python3.8/site-packages/sklearn/utils/__init__.py in <module>
     22 from .murmurhash import murmurhash3_32
---> 23 from .class_weight import compute_class_weight, compute_sample_weight
     24 from . import _joblib

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    161             # look at preceding stack frames for relevant error information.
--> 162             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    163 

/databricks/python/lib/python3.8/site-packages/sklearn/utils/class_weight.py in <module>
      6 
----> 7 from .validation import _deprecate_positional_args
      8 

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    161             # look at preceding stack frames for relevant error information.
--> 162             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    163 

/databricks/python/lib/python3.8/site-packages/sklearn/utils/validation.py in <module>
     25 
---> 26 from .fixes import _object_dtype_isnan, parse_version
     27 from .. import get_config as _get_config

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    161             # look at preceding stack frames for relevant error information.
--> 162             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    163 

/databricks/python/lib/python3.8/site-packages/sklearn/utils/fixes.py in <module>
     19 import scipy
---> 20 import scipy.stats
     21 from scipy.sparse.linalg import lsqr as sparse_lsqr  # noqa

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    161             # look at preceding stack frames for relevant error information.
--> 162             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    163 

/databricks/python/lib/python3.8/site-packages/scipy/stats/__init__.py in <module>
    484                                DegenerateDataWarning, FitError)
--> 485 from ._stats_py import *
    486 from ._variation import variation

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    161             # look at preceding stack frames for relevant error information.
--> 162             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    163 

/databricks/python/lib/python3.8/site-packages/scipy/stats/_stats_py.py in <module>
     40 from scipy.ndimage import _measurements
---> 41 from scipy._lib._util import (check_random_state, MapWrapper,
     42                               rng_integers, _rename_parameter, _contains_nan)

ImportError: cannot import name '_rename_parameter' from 'scipy._lib._util' (/databricks/python/lib/python3.8/site-packages/scipy/_lib/_util.py)

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
<command-632418863495886> in <module>
      3 import plotly.express as plx
      4 
----> 5 from transformers import pipeline
      6 # from transformers import AutoTokenizer

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    160             # Import the desired module. If you’re seeing this while debugging a failed import,
    161             # look at preceding stack frames for relevant error information.
--> 162             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    163 
    164             is_root_import = thread_local._nest_level == 1

/usr/lib/python3.8/importlib/_bootstrap.py in _handle_fromlist(module, fromlist, import_, recursive)

/databricks/python/lib/python3.8/site-packages/transformers/utils/import_utils.py in __getattr__(self, name)
   1098             value = self._get_module(name)
   1099         elif name in self._class_to_module.keys():
-> 1100             module = self._get_module(self._class_to_module[name])
   1101             value = getattr(module, name)
   1102         else:

/databricks/python/lib/python3.8/site-packages/transformers/utils/import_utils.py in _get_module(self, module_name)
   1110             return importlib.import_module("." + module_name, self.__name__)
   1111         except Exception as e:
-> 1112             raise RuntimeError(
   1113                 f"Failed to import {self.__name__}.{module_name} because of the following error (look up to see its"
   1114                 f" traceback):\n{e}"

RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
cannot import name '_rename_parameter' from 'scipy._lib._util' (/databricks/python/lib/python3.8/site-packages/scipy/_lib/_util.py)
```

### Who can help?

_No response_

### 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

```
from transformers import pipeline
```

### Expected behavior

Successful import of pipeline
Hi @k3ybladewielder, thanks for raising this issue.

The error is coming from python not being able to import a specific scipy module and so isn't a `transformers` related bug per se. 

I would try reinstalling transformers with a package manager and the `sklearn` option as it should install all the necessary dependencies in your environment: `pip install transformers[sklearn] --force-reinstall`<|||||>@amyeroberts thanks for the answer. Its works<|||||>**can yall help me too:**
```
from transformers import pipeline
```

```
Failed to import transformers.pipelines because of the following error (look up to see its traceback):
Unable to convert function return value to a Python type! The signature was
	() -> handle
```

**full trace of error:**

```
TypeError                                 Traceback (most recent call last)
File ~/anaconda3/lib/python3.9/site-packages/transformers/utils/import_utils.py:1099, in _LazyModule._get_module(self, module_name)
   1098 try:
-> 1099     return importlib.import_module("." + module_name, self.__name__)
   1100 except Exception as e:

File ~/anaconda3/lib/python3.9/importlib/__init__.py:127, in import_module(name, package)
    126         level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1030, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1007, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:986, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:680, in _load_unlocked(spec)

File <frozen importlib._bootstrap_external>:850, in exec_module(self, module)

File <frozen importlib._bootstrap>:228, in _call_with_frames_removed(f, *args, **kwds)

File ~/anaconda3/lib/python3.9/site-packages/transformers/pipelines/__init__.py:44, in <module>
     35 from ..utils import (
     36     HUGGINGFACE_CO_RESOLVE_ENDPOINT,
     37     is_kenlm_available,
   (...)
     42     logging,
     43 )
---> 44 from .audio_classification import AudioClassificationPipeline
     45 from .automatic_speech_recognition import AutomaticSpeechRecognitionPipeline

File ~/anaconda3/lib/python3.9/site-packages/transformers/pipelines/audio_classification.py:21, in <module>
     20 from ..utils import add_end_docstrings, is_torch_available, is_torchaudio_available, logging
---> 21 from .base import PIPELINE_INIT_ARGS, Pipeline
     24 if is_torch_available():

File ~/anaconda3/lib/python3.9/site-packages/transformers/pipelines/base.py:35, in <module>
     34 from ..image_processing_utils import BaseImageProcessor
---> 35 from ..modelcard import ModelCard
     36 from ..models.auto.configuration_auto import AutoConfig

File ~/anaconda3/lib/python3.9/site-packages/transformers/modelcard.py:48, in <module>
     32 from .models.auto.modeling_auto import (
     33     MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES,
     34     MODEL_FOR_CAUSAL_LM_MAPPING_NAMES,
   (...)
     46     MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING_NAMES,
     47 )
---> 48 from .training_args import ParallelMode
     49 from .utils import (
     50     MODEL_CARD_NAME,
     51     cached_file,
   (...)
     57     logging,
     58 )

File ~/anaconda3/lib/python3.9/site-packages/transformers/training_args.py:30, in <module>
     29 from .debug_utils import DebugOption
---> 30 from .trainer_utils import (
     31     EvaluationStrategy,
     32     FSDPOption,
     33     HubStrategy,
     34     IntervalStrategy,
     35     SchedulerType,
     36     ShardedDDPOption,
     37 )
     38 from .utils import (
     39     ExplicitEnum,
     40     cached_property,
   (...)
     53     requires_backends,
     54 )

File ~/anaconda3/lib/python3.9/site-packages/transformers/trainer_utils.py:48, in <module>
     47 if is_tf_available():
---> 48     import tensorflow as tf
     51 def seed_worker(_):

File ~/anaconda3/lib/python3.9/site-packages/tensorflow/__init__.py:37, in <module>
     35 import typing as _typing
---> 37 from tensorflow.python.tools import module_util as _module_util
     38 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader

File ~/anaconda3/lib/python3.9/site-packages/tensorflow/python/__init__.py:42, in <module>
     39 # pylint: enable=wildcard-import
     40 
     41 # Bring in subpackages.
---> 42 from tensorflow.python import data
     43 from tensorflow.python import distribute

File ~/anaconda3/lib/python3.9/site-packages/tensorflow/python/data/__init__.py:21, in <module>
     20 # pylint: disable=unused-import
---> 21 from tensorflow.python.data import experimental
     22 from tensorflow.python.data.ops.dataset_ops import AUTOTUNE

File ~/anaconda3/lib/python3.9/site-packages/tensorflow/python/data/experimental/__init__.py:96, in <module>
     95 # pylint: disable=unused-import
---> 96 from tensorflow.python.data.experimental import service
     97 from tensorflow.python.data.experimental.ops.batching import dense_to_ragged_batch

File ~/anaconda3/lib/python3.9/site-packages/tensorflow/python/data/experimental/service/__init__.py:419, in <module>
     15 """API for using the tf.data service.
     16 
     17 This module contains:
   (...)
    416   job of ParameterServerStrategy).
    417 """
--> 419 from tensorflow.python.data.experimental.ops.data_service_ops import distribute
    420 from tensorflow.python.data.experimental.ops.data_service_ops import from_dataset_id

File ~/anaconda3/lib/python3.9/site-packages/tensorflow/python/data/experimental/ops/data_service_ops.py:22, in <module>
     21 from tensorflow.python import tf2
---> 22 from tensorflow.python.data.experimental.ops import compression_ops
     23 from tensorflow.python.data.experimental.service import _pywrap_server_lib

File ~/anaconda3/lib/python3.9/site-packages/tensorflow/python/data/experimental/ops/compression_ops.py:16, in <module>
     15 """Ops for compressing and uncompressing dataset elements."""
---> 16 from tensorflow.python.data.util import structure
     17 from tensorflow.python.ops import gen_experimental_dataset_ops as ged_ops

File ~/anaconda3/lib/python3.9/site-packages/tensorflow/python/data/util/structure.py:22, in <module>
     20 import wrapt
---> 22 from tensorflow.python.data.util import nest
     23 from tensorflow.python.framework import composite_tensor

File ~/anaconda3/lib/python3.9/site-packages/tensorflow/python/data/util/nest.py:34, in <module>
     16 """## Functions for working with arbitrarily nested sequences of elements.
     17 
     18 NOTE(mrry): This fork of the `tensorflow.python.util.nest` module
   (...)
     31    arrays.
     32 """
---> 34 from tensorflow.python.framework import sparse_tensor as _sparse_tensor
     35 from tensorflow.python.util import _pywrap_utils

File ~/anaconda3/lib/python3.9/site-packages/tensorflow/python/framework/sparse_tensor.py:24, in <module>
     23 from tensorflow.python.framework import composite_tensor
---> 24 from tensorflow.python.framework import constant_op
     25 from tensorflow.python.framework import dtypes

File ~/anaconda3/lib/python3.9/site-packages/tensorflow/python/framework/constant_op.py:25, in <module>
     24 from tensorflow.python.eager import context
---> 25 from tensorflow.python.eager import execute
     26 from tensorflow.python.framework import dtypes

File ~/anaconda3/lib/python3.9/site-packages/tensorflow/python/eager/execute.py:21, in <module>
     20 from tensorflow.python.eager import core
---> 21 from tensorflow.python.framework import dtypes
     22 from tensorflow.python.framework import ops

File ~/anaconda3/lib/python3.9/site-packages/tensorflow/python/framework/dtypes.py:34, in <module>
     32 from tensorflow.core.function import trace_type
---> 34 _np_bfloat16 = _pywrap_bfloat16.TF_bfloat16_type()
     37 class DTypeMeta(type(_dtypes.DType), abc.ABCMeta):

TypeError: Unable to convert function return value to a Python type! The signature was
	() -> handle

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
Input In [11], in <cell line: 2>()
      1 import gradio as gr                   # UI library
----> 2 from transformers import pipeline

File <frozen importlib._bootstrap>:1055, in _handle_fromlist(module, fromlist, import_, recursive)

File ~/anaconda3/lib/python3.9/site-packages/transformers/utils/import_utils.py:1089, in _LazyModule.__getattr__(self, name)
   1087     value = self._get_module(name)
   1088 elif name in self._class_to_module.keys():
-> 1089     module = self._get_module(self._class_to_module[name])
   1090     value = getattr(module, name)
   1091 else:

File ~/anaconda3/lib/python3.9/site-packages/transformers/utils/import_utils.py:1101, in _LazyModule._get_module(self, module_name)
   1099     return importlib.import_module("." + module_name, self.__name__)
   1100 except Exception as e:
-> 1101     raise RuntimeError(
   1102         f"Failed to import {self.__name__}.{module_name} because of the following error (look up to see its"
   1103         f" traceback):\n{e}"
   1104     ) from e

RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
Unable to convert function return value to a Python type! The signature was
	() -> handle
```
<|||||>@CliffLopes could you open a new issue, including all the information requested in the issue template e.g. running environment etc. ? Just from the traceback, it looks like the issue is coming from the tensorflow installed in the environment. In the issue, please make sure to include any relevant information about tensorflow e.g. version and how it was installed.