Python Forum
ImportError: cannot import name 'scipy_namespace_for' from 'scipy._lib._array_api'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ImportError: cannot import name 'scipy_namespace_for' from 'scipy._lib._array_api'
#1
import numpy as np
import keras
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler(feature_range=(0,1))
import pytse_client as tse
import tensorflow as tf
import seaborn as sns
from timeit import default_timer as timer
from keras.layers import LSTM, Dense, Dropout,Convolution1D, Activation, MaxPooling1D, Flatten,Input
from keras.models import Model, Sequential, load_model
from matplotlib.pylab import rcParams
from keras.utils import to_categorical
from tensorflow.keras import optimizers
from tensorflow.keras.callbacks import EarlyStopping
from sklearn.metrics import mean_squared_error,accuracy_score,mean_absolute_error
from math import sqrt
import math
from tensorflow.keras import layers
from keras.callbacks import TensorBoard
from time import time
from tqdm.keras import TqdmCallback
Error:
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) Cell In[9], line 5 3 import matplotlib.pyplot as plt 4 import pandas as pd ----> 5 from sklearn.preprocessing import MinMaxScaler 6 scaler = MinMaxScaler(feature_range=(0,1)) 7 import pytse_client as tse File E:\Softwares\Python\Lib\site-packages\sklearn\__init__.py:84 70 # We are not importing the rest of scikit-learn during the build 71 # process, as it may not be compiled yet 72 else: (...) 78 # later is linked to the OpenMP runtime to make it possible to introspect 79 # it and importing it first would fail if the OpenMP dll cannot be found. 80 from . import ( 81 __check_build, # noqa: F401 82 _distributor_init, # noqa: F401 83 ) ---> 84 from .base import clone 85 from .utils._show_versions import show_versions 87 __all__ = [ 88 "calibration", 89 "cluster", (...) 130 "show_versions", 131 ] File E:\Softwares\Python\Lib\site-packages\sklearn\base.py:19 17 from ._config import config_context, get_config 18 from .exceptions import InconsistentVersionWarning ---> 19 from .utils._estimator_html_repr import _HTMLDocumentationLinkMixin, estimator_html_repr 20 from .utils._metadata_requests import _MetadataRequester, _routing_enabled 21 from .utils._param_validation import validate_parameter_constraints File E:\Softwares\Python\Lib\site-packages\sklearn\utils\__init__.py:11 9 from . import _joblib, metadata_routing 10 from ._bunch import Bunch ---> 11 from ._chunking import gen_batches, gen_even_slices 12 from ._estimator_html_repr import estimator_html_repr 14 # Make _safe_indexing importable from here for backward compat as this particular 15 # helper is considered semi-private and typically very useful for third-party 16 # libraries that want to comply with scikit-learn's estimator API. In particular, 17 # _safe_indexing was included in our public API documentation despite the leading 18 # `_` in its name. File E:\Softwares\Python\Lib\site-packages\sklearn\utils\_chunking.py:8 5 import numpy as np 7 from .._config import get_config ----> 8 from ._param_validation import Interval, validate_params 11 def chunk_generator(gen, chunksize): 12 """Chunk generator, ``gen`` into lists of length ``chunksize``. The last 13 chunk may have a length less than ``chunksize``.""" File E:\Softwares\Python\Lib\site-packages\sklearn\utils\_param_validation.py:14 11 from scipy.sparse import csr_matrix, issparse 13 from .._config import config_context, get_config ---> 14 from .validation import _is_arraylike_not_scalar 17 class InvalidParameterError(ValueError, TypeError): 18 """Custom exception to be raised when the parameter of a class/method/function 19 does not have a valid type or value. 20 """ File E:\Softwares\Python\Lib\site-packages\sklearn\utils\validation.py:26 24 from .. import get_config as _get_config 25 from ..exceptions import DataConversionWarning, NotFittedError, PositiveSpectrumWarning ---> 26 from ..utils._array_api import _asarray_with_order, _is_numpy_namespace, get_namespace 27 from ..utils.fixes import ComplexWarning, _preserve_dia_indices_dtype 28 from ._isfinite import FiniteStatus, cy_isfinite File E:\Softwares\Python\Lib\site-packages\sklearn\utils\_array_api.py:8 5 from functools import wraps 7 import numpy ----> 8 import scipy.special as special 10 from .._config import get_config 11 from .fixes import parse_version File E:\Softwares\Python\Lib\site-packages\scipy\special\__init__.py:811 808 from ._ufuncs import * 810 # Replace some function definitions from _ufuncs to add Array API support --> 811 from ._support_alternative_backends import ( 812 log_ndtr, ndtr, ndtri, erf, erfc, i0, i0e, i1, i1e, gammaln, 813 gammainc, gammaincc, logit, expit, entr, rel_entr, xlogy, chdtrc) 815 from . import _basic 816 from ._basic import * File E:\Softwares\Python\Lib\site-packages\scipy\special\_support_alternative_backends.py:7 5 import numpy as np 6 import scipy ----> 7 from scipy._lib._array_api import ( 8 array_namespace, scipy_namespace_for, is_numpy, is_torch 9 ) 10 from . import _ufuncs 11 # These don't really need to be imported, but otherwise IDEs might not realize 12 # that these are defined in this file / report an error in __init__.py ImportError: cannot import name 'scipy_namespace_for' from 'scipy._lib._array_api' (E:\Softwares\Python\Lib\site-packages\scipy\_lib\_array_api.py)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Cannot import easysnmp: ImportError: libnetsnmp.so.30 Calab 4 1,790 Jun-08-2023, 08:52 PM
Last Post: Gribouillis
  ImportError: cannot import name 'Pyfhel' from 'Pyfhel' Anldra12 9 4,673 Dec-13-2021, 06:55 PM
Last Post: Anldra12
  ImportError: cannot import name 'get_config' russray2008 0 5,415 Sep-20-2021, 02:18 PM
Last Post: russray2008
  ImportError: cannot import name 'Union' from '_ctypes' (unknown location) ciuffoly 15 12,254 Oct-09-2020, 06:58 AM
Last Post: ciuffoly
  ImportError:DLL Load Failed after importing scipy.sparse.linalg sea_jam 0 2,806 Jul-31-2020, 01:54 AM
Last Post: sea_jam
  ModuleNotFoundError: No module named 'scipy.optimize'; 'scipy' is not a package AaronKR 1 11,847 Jul-09-2020, 02:36 AM
Last Post: bowlofred
  ImportError: cannot import name 'Request' from 'request' abhishek81py 1 4,603 Jun-18-2020, 08:07 AM
Last Post: buran
  ImportError: cannot import name 'MidiEvaluator' from 'parser' (Windows 10) spiffspaceman 4 3,283 May-22-2020, 10:16 PM
Last Post: snippsat
  ImportError: cannot import name 'X ' from ' Y' (Unknown location) Arjunpi 1 5,095 Apr-30-2020, 12:56 AM
Last Post: Larz60+
  problem with mapnik in anaconda python 2: from _mapnik import * ImportError: DLL load parsley 0 2,233 Dec-11-2019, 07:50 AM
Last Post: parsley

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020