I am trying to install the Sklearn python library using
pip install sklearn
in cmd terminal in windows 8.
its shows no error. but when i am executing my code it gives error stating
Traceback (most recent call last):
File "C:\Users\Dipak\Desktop\k means.py", line 5, in <module>
from sklearn.cluster import KMeans
File "C:\Python27\lib\site-packages\sklearn\__init__.py", line 134, in
<module>
from .base import clone
File "C:\Python27\lib\site-packages\sklearn\base.py", line 10, in
<module>
from scipy import sparse
ImportError: No module named scipy
i googled a lot.
Related
I can import numpy with no issues. However, when trying to import easyocr I'm getting the following error:
>>> %Run numpytst.py
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
Traceback (most recent call last):
File "/home/pi/numpytst.py", line 2, in <module>
import easyocr
File "/home/pi/.local/lib/python3.7/site-packages/easyocr/__init__.py", line 1, in <module>
from .easyocr import Reader
File "/home/pi/.local/lib/python3.7/site-packages/easyocr/easyocr.py", line 3, in <module>
from .detection import get_detector, get_textbox
File "/home/pi/.local/lib/python3.7/site-packages/easyocr/detection.py", line 9, in <module>
from .craft_utils import getDetBoxes, adjustResultCoordinates
File "/home/pi/.local/lib/python3.7/site-packages/easyocr/craft_utils.py", line 10, in <module>
from scipy.ndimage import label
File "/home/pi/.local/lib/python3.7/site-packages/scipy/ndimage/__init__.py", line 151, in <module>
from .filters import *
File "/home/pi/.local/lib/python3.7/site-packages/scipy/ndimage/filters.py", line 37, in <module>
from . import _nd_image
ImportError: numpy.core.multiarray failed to import
Environment:
Raspberry Pi 3B
Python 3.7.3
numpy 1.16.6
Have you tried to upgrade to a more recent version? like 1.20.x. I solved a similar Error by simply upgrading my NumPy to ver 1.20.3.
The reason could be the mismatch between dependencies. This worked for me:
pip install numpy --upgrade
While trying to import sklearn, i come across the following error message :
AttributeError: module 'numpy' has no attribute '__config__'
I did install and updated both numpy and sklearn with conda but still get the same error. Any ideas?
import sklearn
Get error message:
Traceback (most recent call last):
File "<ipython-input-35-b7c74cbf5af0>", line 1, in <module>
import sklearn
File "C:\Users\sound\Documents\Conda\lib\site-packages\sklearn\__init__.py", line 82, in <module>
from .base import clone
File "C:\Users\sound\Documents\Conda\lib\site-packages\sklearn\base.py", line 20, in <module>
from .utils import _IS_32BIT
File "C:\Users\sound\Documents\Conda\lib\site-packages\sklearn\utils\__init__.py", line 20, in <module>
from scipy.sparse import issparse
File "C:\Users\sound\Documents\Conda\lib\site-packages\scipy\sparse\__init__.py", line 229, in <module>
from .base import *
File "C:\Users\sound\Documents\Conda\lib\site-packages\scipy\sparse\base.py", line 7, in <module>
from scipy._lib._numpy_compat import broadcast_to
File "C:\Users\sound\Documents\Conda\lib\site-packages\scipy\_lib\_numpy_compat.py", line 16, in <module>
_assert_warns = np.testing.assert_warns
File "C:\Users\sound\Documents\Conda\lib\site-packages\numpy\__init__.py", line 213, in __getattr__
import numpy.testing as testing
File "C:\Users\sound\Documents\Conda\lib\site-packages\numpy\testing\__init__.py", line 12, in <module>
from ._private.utils import *
File "C:\Users\sound\Documents\Conda\lib\site-packages\numpy\testing\_private\utils.py", line 57, in <module>
HAS_LAPACK64 = hasattr(numpy.__config__, 'lapack_ilp64_opt_info')
File "C:\Users\sound\Documents\Conda\lib\site-packages\numpy\__init__.py", line 220, in __getattr__
"{!r}".format(__name__, attr))
AttributeError: module 'numpy' has no attribute '__config__'
---
I had the exact same problem using the binary numpy 1.18.1 package from piwheels on my RasperryPi 4. Do you also happen to try to use this on a Raspberry Pi?
If yes, then:
It works after uninstalling numpy and then retrieving numpy 1.18.1 from pypi instead of from piwheels (had to compile from source though - it takes roughly 15 minutes).
There seems to be something wrong with the piwheels package - I don't know what it is.
The following two commands should solve your problem:
pip3 uninstall numpy
pip3 install numpy==1.18.1 --no-binary :all:
The first command uninstalls your numpy package. The second one retrieves numpy version 1.18.1 where the switch --no-binary :all: tells pip to not get any binary packages, i.e. from piwheels, but instead compile from source.
i'm using python3 in my raspi. and i can't get sklearn to work or import pproperly in a code. i already tried to uninstall all numpy versions on my raspi. then only install numpy in python3 using: sudo apt-get install python3-numpy but i can't still get it to work. please help me everyone :(
thank you in advanced
this is the traceback of the error when importing sklearn
>>>
import sklearn
Traceback (most recent call last):
File "__init__.pxd", line 987, in numpy.import_array
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/sklearn/__init__.py", line 134, in <module>
from .base import clone
File "/usr/local/lib/python3.5/dist-packages/sklearn/base.py", line 13, in <module>
from .utils.fixes import signature
File "/usr/local/lib/python3.5/dist-packages/sklearn/utils/__init__.py", line 10, in <module>
from .murmurhash import murmurhash3_32
File "sklearn/utils/murmurhash.pyx", line 26, in init sklearn.utils.murmurhash
File "__init__.pxd", line 989, in numpy.import_array
ImportError: numpy.core.multiarray failed to import
I am really new to python and I am trying to install the statsmodels module. It seems that since I am on a 64 bits I need to use the following unofficial website http://www.lfd.uci.edu/ I did all I know about how to download a whl and I did download it and used the pip afterwards and all work fine. now when I do pip install statsmodels it work fine. However, in my shell after I try import the stats models I am getting
import statsmodels
Traceback (most recent call last): File "<pyshell#7>", line 1, in <module>
import statsmodels File "D:\Python34\lib\site-packages\statsmodels\__init__.py", line 8, in <module>
from .tools.sm_exceptions import (ConvergenceWarning, CacheWriteWarning, File "D:\Python34\lib\site-packages\statsmodels\tools\__init__.py", line 1, in <module>
from .tools import add_constant, categorical File "D:\Python34\lib\site-packages\statsmodels\tools\tools.py", line 8, in <module>
from scipy.linalg import svdvals File "D:\Python34\lib\site-packages\scipy\linalg\__init__.py", line 174, in <module>
from .misc import * File "D:\Python34\lib\site-packages\scipy\linalg\misc.py", line 5, in <module>
from .blas import get_blas_funcs File "D:\Python34\lib\site-packages\scipy\linalg\blas.py", line 155, in <module>
from scipy.linalg import _fblas ImportError: DLL load failed: The specified module could not be found.
Any help would be much appreciated.
Thank you in advance
I have just update my sklearn to version 0.16.1. As a result, if I try to import:
from sklearn import linear_model
I get the following error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/sklearn/linear_model/__init__.py", line 12, in <module>
from .base import LinearRegression
File "/usr/local/lib/python2.7/dist-packages/sklearn/linear_model/base.py", line 30, in <module>
from ..utils.sparsefuncs import mean_variance_axis, inplace_column_scale
ImportError: cannot import name mean_variance_axis
Does anybody know what is the reason for this problem and how it can be resolved?
The problem has been resolved by the following steps:
Uninstalling scikit-learn.
Manually delete sklearn directory in the /usr/local/lib/python2.7/dist-packages/ directory.
pip install the newest version of the scikit-learn.
However, I got another problem by doing that (Illegal instruction (core dumped)). More details can be found here.