ModuleNotFoundError: No module named 'scipy.sparse' - python

Traceback (most recent call last):
File "C:\Users\Dell\.spyder-py3\SPYDER PROGRAMMING\temp.py", line 54, in <module>
from sklearn.feature_extraction.text import TfidfVectorizer
File "C:\Users\Dell\anaconda3\lib\site-packages\sklearn\__init__.py", line 82, in <module>
from .base import clone
File "C:\Users\Dell\anaconda3\lib\site-packages\sklearn\base.py", line 17, in <module>
from .utils import _IS_32BIT
File "C:\Users\Dell\anaconda3\lib\site-packages\sklearn\utils\__init__.py", line 20, in <module>
from scipy.sparse import issparse
ModuleNotFoundError: No module named 'scipy.sparse'
I have scipy in "conda list -n base" so i have no clue how to solve this

Related

cannot import name '__version__' from partially initialized module 'keras' (most likely due to a circular import)

I am trying to use mrcnn.model and am running into a circular import error. How do I fix this?
Traceback:
Traceback (most recent call last):
File "C:/Users/rinat/PycharmProjects/DSTI_CV_project/Helper functions.py", line 3, in <module>
import mrcnn.model
File "C:\Users\rinat\PycharmProjects\SE_2\venv\lib\site-packages\mrcnn\model.py", line 16, in <module>
import tensorflow.keras as keras
File "C:\Users\rinat\PycharmProjects\SE_2\venv\lib\site-packages\keras\api\_v2\keras\__init__.py", line 12, in <module>
from keras import __version__
File "C:\Users\rinat\PycharmProjects\SE_2\venv\lib\site-packages\keras\__init__.py", line 21, in <module>
from keras import models
File "C:\Users\rinat\PycharmProjects\SE_2\venv\lib\site-packages\keras\models\__init__.py", line 24, in <module>
from keras.models.cloning import _clone_functional_model
File "C:\Users\rinat\PycharmProjects\SE_2\venv\lib\site-packages\keras\models\cloning.py", line 25, in <module>
from keras.engine import training_v1
File "C:\Users\rinat\PycharmProjects\SE_2\venv\lib\site-packages\keras\engine\training_v1.py", line 47, in <module>
from tensorflow.keras.optimizers import SGD
File "C:\Users\rinat\PycharmProjects\SE_2\venv\lib\site-packages\keras\api\_v2\keras\optimizers\__init__.py", line 11, in <module>
from keras.api._v2.keras.optimizers import experimental
File "C:\Users\rinat\PycharmProjects\SE_2\venv\lib\site-packages\keras\api\__init__.py",
line 8, in <module>
from keras.api import keras
File "C:\Users\rinat\PycharmProjects\SE_2\venv\lib\site-packages\keras\api\keras\__init__.py", line 12, in <module>
from keras import __version__
ImportError: cannot import name '__version__' from partially initialized module 'keras' (most likely due to a circular import) (C:\Users\rinat\PycharmProjects\SE_2\venv\lib\site-packages\keras\__init__.py)

AttributeError: module 'numpy.random' has no attribute 'mtrand'

After having installed the pyclustertend package with pip install pyclustertend, I now try to import it into Python:
from pyclustertent import ivat
However, I get the following error while doing so:
Traceback (most recent call last):
File "", line 1, in
from pyclustertend import ivat
File "C:\Users\Emil\AppData\Roaming\Python\Python38\site-packages\pyclustertend_init_.py", line 1, in
from .hopkins import hopkins # noqa: F401
File "C:\Users\Emil\AppData\Roaming\Python\Python38\site-packages\pyclustertend\hopkins.py", line 5, in <module>
from sklearn.neighbors import BallTree
File "C:\Users\Emil\Anaconda3\lib\site-packages\sklearn\__init__.py", line 82, in <module>
from .base import clone
File "C:\Users\Emil\Anaconda3\lib\site-packages\sklearn\base.py", line 17, in <module>
from .utils import _IS_32BIT
File "C:\Users\Emil\Anaconda3\lib\site-packages\sklearn\utils\__init__.py", line 29, in <module>
from .fixes import parse_version, threadpool_info
File "C:\Users\Emil\Anaconda3\lib\site-packages\sklearn\utils\fixes.py", line 47, in <module>
class loguniform(scipy.stats.reciprocal):
File "C:\Users\Emil\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py", line 1601, in __init__
super(rv_continuous, self).__init__(seed)
File "C:\Users\Emil\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py", line 588, in __init__
self._random_state = check_random_state(seed)
File "C:\Users\Emil\Anaconda3\lib\site-packages\scipy\_lib\_util.py", line 202, in check_random_state
return np.random.mtrand._rand
AttributeError: module 'numpy.random' has no attribute 'mtrand'
I suspected this has to do with the Numpy version. However, during the installation, it updated numpy to an older version:
Successfully uninstalled numpy-1.23.4
Successfully installed numpy-1.20.3 pyclustertend-1.8.2
What do I need to do to use this package?

sklearn.utils module is not found

So I have sklearn installed, but for some reason whenever I try to import sklearn it says:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\joeya\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sklearn\__init__.py", line 82, in <module>
from .base import clone
File "C:\Users\joeya\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sklearn\base.py", line 17, in <module>
from .utils import _IS_32BIT
ModuleNotFoundError: No module named 'sklearn.utils'
Does anyone have any ideas? I have Python 3.8.7 installed.

python sklearn import failed on libquadmath.so.0 in 3.5.1

Getting import Error while importing sklearn , the only Error code what it says is libquadmath.so.0 which i'm unale to see on the pkg path but same module works fine in 3.6.1.
>>> import sklearn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/python3/lib/python3.5/site-packages/sklearn/__init__.py", line 57, in <module>
from .base import clone
File "/python3/lib/python3.5/site-packages/sklearn/base.py", line 11, in <module>
from .utils.fixes import signature
File "/python3/lib/python3.5/site-packages/sklearn/utils/__init__.py", line 11, in <module>
from .validation import (as_float_array,
File "/python3/lib/python3.5/site-packages/sklearn/utils/validation.py", line 16, in <module>
from ..utils.fixes import signature
File "/python3/lib/python3.5/site-packages/sklearn/utils/fixes.py", line 324, in <module>
from scipy.sparse.linalg import lsqr as sparse_lsqr
File "/python3/lib/python3.5/site-packages/scipy-0.18.0rc2-py3.5-linux-x86_64.egg/scipy/sparse/linalg/__init__.py", line 112, in <module>
from .isolve import *
File "/python3/lib/python3.5/site-packages/scipy-0.18.0rc2-py3.5-linux-x86_64.egg/scipy/sparse/linalg/isolve/__init__.py", line 6, in <module>
from .iterative import *
File "/python3/lib/python3.5/site-packages/scipy-0.18.0rc2-py3.5-linux-x86_64.egg/scipy/sparse/linalg/isolve/iterative.py", line 7, in <module>
from . import _iterative
ImportError: libquadmath.so.0: cannot open shared object file: No such file or directory

AttributeError: 'module' object has no attribute 'tokenize'

I have nltk installed in my virtualenv. When I do pip freeze , among other packages I can see nltk==3.2.1.
I am using Ubuntu 14.04 and python 2.7. And After activating virtualenv, when I try to import nltk from python shell, I get following error.
>>> import nltk
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/nltk/__init__.py", line 128, in <module>
from nltk.chunk import * File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/nltk/chunk/__init__.py", line 157, in <module>
from nltk.chunk.api import ChunkParserI File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/nltk/chunk/api.py", line 13, in <module>
from nltk.parse import ParserI File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/nltk/parse/__init__.py", line 79, in <module>
from nltk.parse.transitionparser import TransitionParser File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/nltk/parse/transitionparser.py", line 21, in <module>
from sklearn.datasets import load_svmlight_file File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/sklearn/__init__.py", line 57, in <module>
from .base import clone File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/sklearn/base.py", line 11, in <module>
from .utils.fixes import signature File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/sklearn/utils/__init__.py", line 17, in <module>
from ..externals.joblib import cpu_count File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/sklearn/externals/joblib/__init__.py", line 127, in <module>
from .parallel import Parallel File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 30, in <module>
from .format_stack import format_exc, format_outer_frames File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/sklearn/externals/joblib/format_stack.py", line 35, in <module>
generate_tokens = tokenize.tokenize AttributeError: 'module' object has no attribute 'tokenize'
How can I solve this problem?

Categories

Resources