dispatcher not defined when importing module - python-3.x

I was attempting to import some modules in a Spyder IDE:
from sklearn.neighbors import KNeighborsClassifier
from mlxtend.feature_selection import ExhaustiveFeatureSelector
For both of the import statements above I get the error:
"NameError: name 'dispatcher' is not defined"
Tried install package "dispatcher"

I had the same error, but while using pandas.DataFrame.sample. I managed to track the error to numpy.random.choice, I was using version 1.15. I updated numpy to version 1.17.3 and the issue was solved. If you are using conda, you can do so by typing
conda update numpy=1.17.3
on the Anaconda prompt.

Related

ImportError: cannot import name 'cluster_resolver'

I get this error when trying to setup Unity3d ml-agents
ImportError: cannot import name 'cluster_resolver'
Following https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Installation.md tutorial
from tensorflow.contrib import cluster_resolver
Error happens when I try to run mlagents-learn --help
I am on MacOS with Python 3.6
Fixed by using Tensorflow 1.7.0 instead of 1.7.1 as in the tutorial.

ImportError: cannot import name '_print_elapsed_time'

Hi so I'm trying to use the make_pipeline module in sklearn. But when I try to import it with:
from sklearn.pipeline import make_pipeline
I get this error:
ImportError: cannot import name '_print_elapsed_time'
I've googled it but there seems to be no other posts about this. I tried reinstalling scikitlearn but I still get the same error :/ Anyone have any ideas?
It looks like this was a bug introduced into one of the newer versions of scikit-learn (I got this same issue in version 0.21.2).
I was able to fix this by downgrading to scikit-learn version 0.20.0
>> pip install scikit-learn==0.20.0

Cannot import Sklearn from sklearn.externals.joblib

I am a beginner and I just started with machine learning. I am trying to import classes like imputer from sklearn but i am unable to do it.
from sklearn.preprocessing import Imputer,LabelEncoder,OneHotEncoder,StandardScaler
ImportError: cannot import name 'version' from
'sklearn.externals.joblib'
(C:\ProgramData\Anaconda3\lib\site-packages\sklearn\externals\joblib__init__.py)
I had the same problem.
I have replaced
from sklearn.externals import joblib
with
import joblib
and it works fine in Python 3.7.2
I believe there was an update on Scikit-learn that render that import unusable.
I had my local installation to be version 0.20.3 and this import is pefectly working. But on my server I have installation 0.23.1 and this error pop up. Something must be chaging in the new version.
For my case, use import joblib fix the problem. In your case it seems more complicated. This sounds very much likeky to be caused if you have more than one Scikit-learn version installed on your system. You need to uninstall all of them and do a clean install of sklearn.
The problem sometimes happens due to the version. This may help:
If you has written like this
from sklearn.externals import joblib
Modify it as this:
import joblib
Try
python -m pip install sklearn --upgrade
and
python -m pip install joblib --upgrade
and then, use this :
import joblib
Good luck.
import joblib
This works for me. Actually I was having that kinda challenge

How to import WordEmbeddingSimilarityIndex function from gensim module?

When i try to import WordEmbeddingSimilarityIndex, it's giving me the following error:
>> from gensim.models import WordEmbeddingSimilarityIndex
ImportError: cannot import name 'WordEmbeddingSimilarityIndex
The same issue occurs for SparseTermSimilarityMatrix function:
>> from gensim.similarities import SparseTermSimilarityMatrix
ImportError: cannot import name 'SparseTermSimilarityMatrix
Note: I have installed and imported gensim, gensim.models and gensim.similarities. But still it's giving me the ImportError while importing the above mentioned functions.
Can you tell me what I am doing wrong, please?
Fix is change "models" to "similarities"
from gensim.similarities import WordEmbeddingSimilarityIndex
it works in gensim 4.0.1
Try to check the version of gensim that you are using. Usually, the older versions of gensim cause this issue.
from gensim.models import WordEmbeddingSimilarityIndex
print(gensim.__version__)
if the gensim version is 3.6.x or older update it to 3.7.x or latest version by running the below command. Once you update gensim version should get rid of this issue.
pip install --upgrade gensim

Import error, there is no module named numpy, but it says that it is installed?

So I trying to install and run from MSFT the cntk, you know, just for fun. Anyway, I keep getting this error which says:
import numpy as np
ModuleNotFoundError: No module named 'numpy'
Now I have looked around here a little and I found a post saying that I needed to install the latest version of NumPy, but when I go to do that, I get back this:
Requirement already satisfied: NumPy in c:\users\username\appdata\local\continuum\anaconda3\envs\cntk-py34\lib\site-packages
SO I really have no idea what is going on here.
Anyway, thanks in advance.
Is your IDE linked to Anaconda env? If you open up the Anaconda prompt and import numpy do you get the same error?
You probably have an environment outside of Anaconda which does not have numpy installed.
In my case, I was executing [filename].py from the Anaconda prompt as I would a batch file and was getting this error. I confirmed numpy was install by executing pip list.
Funning python and passing the script file name as an argument, eg python [filename].py, correctly imported the numpy module and executed the script without error.

Resources