I can't seem to get from sklearn.cluster import KMean to work in Python I did the whole pip install scipy/numpy and they are installed in python but I can't get the KMeans into it at the moment I have found a load of ones that are similar to my problem but I can't seem to get it working with mine.
When I do from sklearn.cluster import KMeans I just get an error that says
Traceback (most recent call last):
File "<pyshell#20>", line 1, in <module>
import sklearn
File "C:\Python34\lib\site-packages\sklearn\__init__.py", line 56, in <module>
from . import __check_build
ImportError: cannot import name '__check_build'
Can someone please help me I would be forever grateful!!!
This usually happens if you don't have scipy installed, so run this in your command prompt:
pip install scipy
Try this:
sudo pip install scipy
Then in Python:
import scipy
Related
I am using python39 and have imported the libraries 'numpy, scipy, matplotlib, scikit-learn and sklearn.
I am then trying to use a command with sklearn library and it is not working with the below error
from sklearn import neighbors
Traceback (most recent call last):
File "<pyshell#32>", line 1, in <module>
from sklearn import neighbors
File "C:\Python39\lib\site-packages\sklearn\__init__.py", line 80, in <module>
from .base import clone
ImportError: DLL load failed while importing qhull: The specified module could not be found."
I used the below commands
C:\Python39\Scripts>pip install mkl_fft-1.2.0-cp39-cp39-win_amd64.whl force
C:\Python39\Scripts>pip install mkl_random-1.2.0-cp39-cp39-win_amd64.whl force
C:\Python39\Scripts>pip install mkl_random-1.2.0-cp39-cp39-win_amd64.whl force
Then I went back to my python shell and typed
from sklearn import neighbors
It worked
I am new to Python and I am trying to install numpy+mkl and scipy (in the same order), but I get below error when I execute following steps:
import pandas as pd
import numpy as np
from sklearn.preprocessing import LabelEncoder
I am using Python 3.5 (32-bit) on a Windows 7 64-bit OS.
There is a similar question already answered for the exact problem here: ImportError: cannot import name NUMPY_MKL
Going through the answer, I reinstalled my numpy+mkl pkg numpy‑1.11.2+mkl‑cp35‑cp35m‑win32.whl from the mentioned link (http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy) and then reinstalled scipy-0.18.1-cp35-cp35m-win32.whl as well, but that does not solve the problem and I still get the same error:
>>> exec(open("C:\\PythonFiles\\testpy1.py").read())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 3, in <module>
File "C:\Users\msoudagar\AppData\Local\Programs\Python\Python3532\lib\site-packages\sklearn\__init__.py", line 57, in <module>
from .base import clone
File "C:\Users\msoudagar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\sklearn\base.py", line 10, in <module>
from scipy import sparse
File "C:\Users\msoudagar\AppData\Local\Programs\Python\Python3532\lib\site-packages\scipy\__init__.py", line 61, in <module>
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
ImportError: cannot import name 'NUMPY_MKL'
Any inputs would be really helpful!
Try commenting out the line
from numpy._distributor_init import NUMPY_MKL
it might just work regardless.
ImportError: cannot import name NUMPY_MKL
I know this is not the most sophisticated of solutions but, all I had to do was close the IDE(in my case, Pycharm) and re-open it again.
Not sophisticated but effective in my case :).
Check this answer. Solved my problem.
https://stackoverflow.com/a/37294205/2708266
Suggesting to download ready made binary setup from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
pip install xx.whl
I ran into the same issue on Windows with Python 3.5 64 bit. Manually installing numpy+mkl from wheel file solved the issue for me.
Select the appropriate wheel file from here (cp35,win32 for you): and install it using pip install --user Path_to_local_file.whl replacing Path_to_local_file with wherever you saved the .whl file
This is a also a duplicate of ImportError: cannot import name NUMPY_MKL
I have tried all the import methods and upgrading the libraries but still I'm unable to get over this error. I have downloaded and installed all the nltk and corpus data programmatically and it is working in the python shell but i'm getting error.
Traceback (most recent call last):
File "spark.py", line 7, in <module>
from textblob_aptagger import PerceptronTagger
File "/usr/local/lib/python2.7/dist-packages/textblob_aptagger/__init__.py", line 8, in <module>
from textblob_aptagger.taggers import PerceptronTagger
File "/usr/local/lib/python2.7/dist-packages/textblob_aptagger/taggers.py", line 10, in <module>
from textblob.packages import nltk
ImportError: No module named packages
Here's a pastebin to my code and imports..
Same error has been posted on github here. Use this instead to install textblob:
$ pip install -U git+https://github.com/sloria/textblob-aptagger.git#dev
Also, you should change from text.blob import TextBlob as tbto from textblob...
Works for me..
I an new to Python and am not sure how to run this code. I receive the following error:
mona$ python spectral.py
Traceback (most recent call last):
File "spectral.py", line 12, in <module>
from ..base import BaseEstimator, ClusterMixin
ValueError: Attempted relative import in non-package
>>> from ..base import BaseEstimator, ClusterMixin, TransformerMixin
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Attempted relative import in non-package
I am not sure which other files from that repository should I download or which packages should I download to be able to run this code.
Why would you want to run that script?
Install scikit-learn.
sudo pip install scikit-learn
then you can import spectral clustering in your python script:
read:
http://scikit-learn.org/stable/auto_examples/cluster/plot_lena_segmentation.html#example-cluster-plot-lena-segmentation-py
and
http://scikit-learn.org/stable/auto_examples/cluster/plot_segmentation_toy.html#example-cluster-plot-segmentation-toy-py
You have to run it as a package not just the componant.
have you already installed the sklearn package and dependancies?
if not you should check out this page and go from there to install and configure the package.
I am trying to read a *.wav file using scipy. I do it in the following way:
import scipy.io
x = scipy.io.wavfile.read('/usr/share/sounds/purple/receive.wav')
As a result I get the following error message:
Traceback (most recent call last):
File "test3.py", line 1, in <module>
import scipy.io
File "/usr/lib/python2.5/site-packages/scipy/io/__init__.py", line 23, in <module>
from numpy.testing import NumpyTest
ImportError: cannot import name NumpyTest
Does anybody know why scipy cannot import NumpyTest and how it can be fixed?
Looks like you have upgraded your numpy version but haven't installed a corresponding scipy version.
Do you have numpy installed? The package is most likely called numpy or python-numpy if you are running Linux
If your OS package manager does not have numpy package, download it from here