I am trying to use the sklearn.qda package in python. I have installed it successfully but when Itry to import it I get the error message below. Can anybody tell me what should I do to fix this?
In [3]: from sklearn.qda import QDA
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-7d7abf937d66> in <module>()
----> 1 from sklearn.qda import QDA
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/qda.py in <module>()
12
13 from .base import BaseEstimator, ClassifierMixin
---> 14 from .utils.fixes import unique
15 from .utils import check_arrays, array2d
16
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/utils/__init__.py in <module>()
7 import warnings
8
----> 9 from .murmurhash import murmurhash3_32
10 from .validation import (as_float_array, check_arrays, safe_asarray,
11 assert_all_finite, array2d, atleast2d_or_csc,
ImportError: cannot import name murmurhash3_32
I had the same problem, I run:
sudo pip install -U scikit-learn
and now everything is working fine
I started a new shell and this problem went away
I faced the similar situation of getting mumurhash error while installing sklearn.preprocessing library.
I upgraded numpy version from 1.13 to 1.15
using
pip install --upgrade numpy
After this, I was able to import the sklearn library.
I fixed this by upgrading murmurhash to 1.0.5.
I faced a similar problem, so there are mainly two solutions
Either run it in administrator mode and install all the libraries and run in admin mode. Something that I would not recommend
Use virtualenv to install the libraries again and run your command in the virtualenv. This worked for me.
Hope this helps
Related
I'm facing an issue which seems to occur very often but the solutions I found so far did not helped me. When I try to do from top2vec import Top2Vec I get the following error:
ValueError Traceback (most recent call last)
<ipython-input-14-f6d7059c0d66> in <module>
----> 1 from top2vec import Top2Vec
2 model = Top2Vec(documents=data, speed="learn", workers=8)
~/env_env/lib/python3.7/site-packages/top2vec/__init__.py in <module>
----> 1 from top2vec.Top2Vec import Top2Vec
2
3 __version__ = '1.0.26'
~/env_env/lib/python3.7/site-packages/top2vec/Top2Vec.py in <module>
9 from gensim.parsing.preprocessing import strip_tags
10 import umap
---> 11 import hdbscan
12 from wordcloud import WordCloud
13 import matplotlib.pyplot as plt
~/env_env/lib/python3.7/site-packages/hdbscan/__init__.py in <module>
----> 1 from .hdbscan_ import HDBSCAN, hdbscan
2 from .robust_single_linkage_ import RobustSingleLinkage, robust_single_linkage
3 from .validity import validity_index
4 from .prediction import (approximate_predict,
5 membership_vector,
~/env_env/lib/python3.7/site-packages/hdbscan/hdbscan_.py in <module>
19 from scipy.sparse import csgraph
20
---> 21 from ._hdbscan_linkage import (single_linkage,
22 mst_linkage_core,
23 mst_linkage_core_vector,
hdbscan/_hdbscan_linkage.pyx in init hdbscan._hdbscan_linkage()
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject
When I try to upgrade to numpy==1.20.0 like other solutions suggest than I get in trouble with other packages I need (as displayed in the ERROR warnings below)
ERROR: transformers 4.9.1 has requirement huggingface-hub==0.0.12, but you'll have huggingface-hub 0.0.15 which is incompatible.
ERROR: flair 0.8.0.post1 has requirement numpy<1.20.0, but you'll have numpy 1.20.0 which is incompatible.de here
Does anyone has an idea how to work around on this or was facing the similar issue? I would appreciate every kind of hint!!! Thanks in advance!
I have faced the same issue. I Just installed top2vec==1.0.20 this version of Top2Vec using pip, without upgrading Numpy, and also it required joblib library too.
So install both.
I am trying to run the code
import keras
And I am getting this stack trace.
I have tried reinstalling keras and tensorflow but nothing in working.
Here is the stack trace.
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-10-88d96843a926> in <module>
----> 1 import keras
~\Anaconda3\lib\site-packages\keras\__init__.py in <module>
1 from __future__ import absolute_import
2
----> 3 from . import utils
4 from . import activations
5 from . import applications
~\Anaconda3\lib\site-packages\keras\utils\__init__.py in <module>
4 from . import data_utils
5 from . import io_utils
----> 6 from . import conv_utils
7 from . import losses_utils
8 from . import metrics_utils
~\Anaconda3\lib\site-packages\keras\utils\conv_utils.py in <module>
7 from six.moves import range
8 import numpy as np
----> 9 from .. import backend as K
10
11
~\Anaconda3\lib\site-packages\keras\backend\__init__.py in <module>
----> 1 from .load_backend import epsilon
2 from .load_backend import set_epsilon
3 from .load_backend import floatx
4 from .load_backend import set_floatx
5 from .load_backend import cast_to_floatx
~\Anaconda3\lib\site-packages\keras\backend\load_backend.py in <module>
88 elif _BACKEND == 'tensorflow':
89 sys.stderr.write('Using TensorFlow backend.\n')
---> 90 from .tensorflow_backend import *
91 else:
92 # Try and load external backend.
ModuleNotFoundError: No module named 'keras.backend.tensorflow_backend'
Try:
pip install tensorflow==2.2.0
and then
pip install Keras==2.2.0
This worked for me with Python 3.7.
instead of use something like
from keras.backend.tensorflow_backend import set_session
Try to use it like
from keras.backend import set_session
In Tensorflow 2.0.0+ versions you should just put "compat.v1" after tf and dont use "tensorflow_backend" name. Like this:
tf.keras.backend.tensorflow_backend.set_session() -> tf.compat.v1.keras.backend.set_session()
I tried to use anaconda or pip to install tensorflow and keras, and each method met the same problem.
At last I found the problem is because the version of tensorflow or keras. When I install tensorflow==2.2 and keras==2.4.3(latest), no matter which tools I used I will meet this problem.When I install tensorflow==1.14 and keras==2.2, the code works well.
My python version is 3.5.2 under ubuntu 16.04
Just install tensorflow 2.1.0 or 2.2.0 It already has Keras inside. Dont mix using pip and conda. Carry on with what you have started.
pip install tensorflow==2.2.0
or,
conda install tensorflow==2.2.0
Uninstall Keras and reinstall the version 2.2.0 in your system, it will definately work with Tensorflow 2.2. Then you won't have to downgrade you tensorflow ie. less pain of changing codes ;)
pip uninstall keras
pip install Keras==2.2.0
For my case, I had Python 3.7(latest bug fix)
for tensorflow==2.4.1 this works:
from tensorflow.python.keras.backend import set_session
In my case, it was solved by installing a given specific version of Keras.
pip install Keras==2.2.4
I have recently installed imblearn package in jupyter using
!pip show imbalanced-learn
But I am not able to import this package.
from tensorflow.keras import backend
from imblearn.over_sampling import SMOTE
I get the following error
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-20-f19c5a0e54af> in <module>
1 # from sklearn.utils import resample
2 from tensorflow.keras import backend
----> 3 from imblearn.over_sampling import SMOTE
4
5
~/.virtualenvs/p3/lib/python3.6/site-packages/imblearn/__init__.py in <module>
32 Module which allowing to create pipeline with scikit-learn estimators.
33 """
---> 34 from . import combine
35 from . import ensemble
36 from . import exceptions
~/.virtualenvs/p3/lib/python3.6/site-packages/imblearn/combine/__init__.py in <module>
3 """
4
----> 5 from ._smote_enn import SMOTEENN
6 from ._smote_tomek import SMOTETomek
7
~/.virtualenvs/p3/lib/python3.6/site-packages/imblearn/combine/_smote_enn.py in <module>
8 from sklearn.utils import check_X_y
9
---> 10 from ..base import BaseSampler
11 from ..over_sampling import SMOTE
12 from ..over_sampling.base import BaseOverSampler
~/.virtualenvs/p3/lib/python3.6/site-packages/imblearn/base.py in <module>
14 from sklearn.utils.multiclass import check_classification_targets
15
---> 16 from .utils import check_sampling_strategy, check_target_type
17
18
~/.virtualenvs/p3/lib/python3.6/site-packages/imblearn/utils/__init__.py in <module>
5 from ._docstring import Substitution
6
----> 7 from ._validation import check_neighbors_object
8 from ._validation import check_target_type
9 from ._validation import check_sampling_strategy
~/.virtualenvs/p3/lib/python3.6/site-packages/imblearn/utils/_validation.py in <module>
11
12 from sklearn.base import clone
---> 13 from sklearn.neighbors._base import KNeighborsMixin
14 from sklearn.neighbors import NearestNeighbors
15 from sklearn.utils.multiclass import type_of_target
ModuleNotFoundError: No module named 'sklearn.neighbors._base'
Other packages in the environment
numpy==1.16.2
pandas==0.24.2
paramiko==2.1.1
matplotlib==2.2.4
scikit-learn==0.22.1
Keras==2.2.4
tensorflow==1.12.0
tensorboard==1.12.0
tensorflow-hub==0.4.0
xlrd==1.2.0
flask==1.0.2
wtforms==2.2.1
bs4==0.0.1
gensim==3.8.1
spacy==2.2.3
nltk==3.4.5
wordcloud==1.6.0
pymongo==3.10.1
imbalanced-learn==0.6.1
I checked the sklearn package, it contains base module, not _base. But modifying it may not be the right solution. Any other solution to fix this issue.
If in case you want to persist with the latest version of scikit-learn, add the following code to your script or execute the following code in your environment before installing imblearn
import sklearn.neighbors._base
sys.modules['sklearn.neighbors.base'] = sklearn.neighbors._base
This has to be after
pip install sklearn
or in a notebook environment:
!pip install sklearn
This problem stems from the fact that certain modules are named with an underscore in the newer scikit-learn releases
Previous sklearn.neighbors.base has been renamed to sklearn.neighbors._base in version 0.22.1.
You have probably a version of scikit-learn older than that.
Installing the latest release solves the problem:
pip install -U scikit-learn
or
pip install scikit-learn==0.22.1
I had a similar problem trying to import SMOTE from imblearn.over_sampling and my version of scikit-learn was up to date (0.24.1). What worked for me was:
First I downgraded my scikit learn version to 0.22.1 using
pip install scikit-learn==0.22.1
Next, I updated the imbalanced-learn package using:
pip install -U imbalanced-learn
That uninstalled scikit-learn-0.22.1, installed the updated version (scikit-learn-0.24.1), and updated the imbalanced-learn package. Everything worked fine thereafter.
If it is in a particular env, you must copy the _base file or base file to the env from package file.
I had the same problem in my tensorflow env. I just copied _base and base file to my tensorflow env and worked.
So I am trying to get hmmlearn working in Jupyter, and I have come across an error while installing Hmmlearn using pip. I have tried this solution, but it didn't work.
It seems to me that pip does install the _hmmc file, but it does so incorrect. instead it has the name
_hmmc.cp35-win_amd64
and the file extesion is .PYD, instead of .c
When I run the code to import it, I get this error :
ImportError Traceback (most recent call last)
<ipython-input-1-dee84c3d5ff9> in <module>()
7 import os
8 from pyAudioAnalysis import audioBasicIO as aB
----> 9 from pyAudioAnalysis import audioAnalysis as aA
C:\Users\gover_000\Documents\GitHub\Emotion-Recognition-Prototype\pyAudioAnalysis\audioAnalysis.py in <module>()
15 import audioFeatureExtraction as aF
16 import audioTrainTest as aT
---> 17 import audioSegmentation as aS
18 import audioVisualization as aV
19 import audioBasicIO
C:\Users\gover_000\Documents\GitHub\Emotion-Recognition-Prototype\pyAudioAnalysis\audioSegmentation.py in <module>()
16 import sklearn
17 import sklearn.cluster
---> 18 import hmmlearn.hmm
19 import cPickle
20 import glob
C:\Users\gover_000\Anaconda3\envs\python2\lib\site-packages\hmmlearn\hmm.py in <module>()
19 from sklearn.utils import check_random_state
20
---> 21 from .base import _BaseHMM
22 from .utils import iter_from_X_lengths, normalize
23
C:\Users\gover_000\Anaconda3\envs\python2\lib\site-packages\hmmlearn\base.py in <module>()
11 from sklearn.utils.validation import check_is_fitted
12
---> 13 from . import _hmmc
14 from .utils import normalize, log_normalize, iter_from_X_lengths
15
ImportError: cannot import name _hmmc
I don't know why pip just doesn't install it correctly, even when I tried to use --no-cache-dir
Edit: So i figured out what the problem was. my active python enviroment was python 3.5, as i was manually transferring the installed files to my enviroment, it failed because i had the wrong version.
I had to change my active python enviroment: using activate <my_enviroment name>
after that i could just use pip to install it again and it worked this time.
Looking at your error message I guess that you have downloaded the hmmlearn package from GIT. Have you tried using a wheel (*.whl) file instead? You can download one from here. Check out which version fits your python installation.
Then use:
pip install <the_wheel_that_corresponds_to_your_python_version>.whl
Hope it helps.
So i figured out what the problem was. my active python enviroment was python 3.5, as i was manually transferring the installed files to my enviroment, it failed because i had the wrong version. I had to change my active python enviroment: using activate <my_enviroment_name> after that i could just use pip to install it again and it worked this time.
not sure if it could be helpful to anyone but I installed hmmlearn as follows in my Jupyter Lab:
import sys
!{sys.executable} -m pip install hmmlearn
I cannot import caffe into (anaconda-) python.
I'm following a notebook example on "logistic regression on non-image HDF5 data". When I execute the line
import caffe
I get the following error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-17-3524921938b5> in <module>()
8 sys.path.insert(0, caffe_root + 'python')
9
---> 10 import caffe
11
/home/myName/libs/caffe/caffe-master-anaconda-python/python/caffe/__init__.py in <module>()
----> 1 from .pycaffe import Net, SGDSolver
2 from ._caffe import set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver
3 from .proto.caffe_pb2 import TRAIN, TEST
4 from .classifier import Classifier
5 from .detector import Detector
/home/myName/libs/caffe/caffe-master-anaconda-python/python/caffe/pycaffe.py in <module>()
11 import numpy as np
12
---> 13 from ._caffe import Net, SGDSolver
14 import caffe.io
15
ImportError: libjpeg.so.62: cannot open shared object file: No such file or directory
The library libjpeg.so.62 is definetly installed under /usr/lib/i386-linux-gnu/libjpeg.so.62. I don't know what is going wrong here or how to tell anacondapython where to look for libjpeg.so.62.
I already tried out sudo apt-get install libjpeg62:i386 but apt-get says "libjpeg62:i386 is already the newest version. libjpeg62:i386 set to manually installed."
I compiled caffe while modifying "Makefile.config" such that it was pointing it to the ananconda python path. I also exported the PYTHONPATH and PATH of my anaconda directory:
export PATH="/home/myName/libs/anaconda/bin:$PATH"
export PYTHONPATH="/home/myName/libs/caffe/caffe-master-anaconda-python/python:$PYTHONPATH"
Ok I finally found the solution:
I had to sudo apt-get install libjpeg62
After that a new error occurred while trying to import caffe, namely
ImportError: /home/myName/libs/anaconda/bin/../lib/libm.so.6: version `GLIBC_2.15' not found (required by /usr/lib/x86_64-linux-gnu/libx264.so.142)
That could be solved by removing some buggy anaconda libraries thus resorting to the system libraries,quote shelhamer:
"Some versions of Anaconda seem to come with a bad libm. rm ~/anaconda/lib/libm.* takes care of this by reverting to the system libm."
see github bvlc