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
Related
I get an error when importing sklearn in python.
I am using MacBook.
>>> import sklearn
Error:
> Traceback (most recent call last): File
> "<pyshell#1>", line 1, in <module>
> import sklearn File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sklearn/__init__.py",
> line 81, in <module>
> from . import __check_build # noqa: F401 ImportError: cannot import name '__check_build' from 'sklearn'
> (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sklearn/__init__.py)
According to the pypi page for sklearn, you should be using pip install scikit-learn instead of pip install sklearn
Your requirements.txt file needs the line
scikit-learn==0.22.1
or, if you're not storing requirements for the project, then
pip install scikit-learn
on the command line.
I'm simply trying to run a .py file, and not sure why it can't find the torch module. I am pretty sure all modules are up to date, and I can see the torch module in my lib/ folder...
Traceback (most recent call last):
File "ptb-lm.py", line 86, in <module>
import torch
File "C:\Users\Public\Anaconda3\lib\site-packages\torch\__init__.py", line 80, in <module>
from torch._C import *
ImportError: DLL load failed: The specified module could not be found.
To be honest I'm still confused as to when / why use conda or pip but I did check that both were up to date!
Try using anaconda to install torch.
Use this link to download https://pytorch.org/get-started/locally/
Python version : 3.5.2
I getting started with machine learning and things... So I installed sklearn and some other packages form pip. All of them were able to be installed successfully except sklearn so, I downloaded the wheel and installed it from here. It was successfully installed but when i tried to import it in the order to check correct installation, I got tons of error :
Traceback (most recent call last):
File "C:\MyFiles\Programs\Python\PlayGround.py", line 1, in
import sklearn
File "C:\Users\Vaibhav Acharya\AppData\Local\Programs\Python\Python35\lib\site-packages\sklearn__init__.py", line 134, in
from .base import clone
File "C:\Users\Vaibhav Acharya\AppData\Local\Programs\Python\Python35\lib\site-packages\sklearn\base.py", line 12, in
from .utils.fixes import signature
File "C:\Users\Vaibhav Acharya\AppData\Local\Programs\Python\Python35\lib\site-packages\sklearn\utils__init__.py", line 11, in
from .validation import (as_float_array,
File "C:\Users\Vaibhav Acharya\AppData\Local\Programs\Python\Python35\lib\site-packages\sklearn\utils\validation.py", line 18, in
from ..utils.fixes import signature
File "C:\Users\Vaibhav Acharya\AppData\Local\Programs\Python\Python35\lib\site-packages\sklearn\utils\fixes.py", line 144, in
from scipy.sparse.linalg import lsqr as sparse_lsqr # noqa
File "C:\Users\Vaibhav Acharya\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\sparse\linalg__init__.py", line 114, in
from .isolve import *
File "C:\Users\Vaibhav Acharya\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\sparse\linalg\isolve__init__.py", line 6, in
from .iterative import *
File "C:\Users\Vaibhav Acharya\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\sparse\linalg\isolve\iterative.py", line 7, in
from . import _iterative
ImportError: DLL load failed: The specified module could not be found.
And the code was just :
import sklearn
I have already checked correct version of wheel package which, I have downloaded.
How can I correct it and why it is occurring?
The following steps solved my problem :
Uninstalling numpy, sklearn and scipy.
Downloading numpy+mkl and scipy from here.
Firstly installing numpy+mkl and then scipy.
Installing sklearn from pip.
Various things need to be checked:
Check numpy, scipy installation versions.
If they are correct then try to import numpy and scipy.
If they getting imported correctly, then clear your temp(c:/users/username/Appdata/local/temp)folder. Restart the machine and try again.
Still if doesn't work, then uninstall scipy, numpy , sklearn and
reinstall the proper wheel files
Download and install numpy+mkl file.
Currently you might have installed only the numpy file.
Go to: https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
Download the corresponding wheel file in which is suitable for your python installation
pip install "/path_to_thefile/numpy-1.14.6+mkl-cp36-cp36m-win_amd64.whl"
This should help you
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
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.