Hi just updated my version of python from 3.7 to 3.8 I am using pycharm IDE and sklearn was working perfectly fine in the previous version but now when I try to run code that was
However after updating my version it keeps giving the following error.
"C:\Program Files\Python\python.exe" C:/Users/SmithyB/Desktop/test/K-Means.py
Traceback (most recent call last):
File "C:/Users/SmithyB/Desktop/test/K-Means.py", line 6, in <module>
from sklearn.cluster import KMeans
File "C:\Program Files\Python\lib\site-packages\sklearn\__init__.py", line 80, in <module>
from .base import clone
File "C:\Program Files\Python\lib\site-packages\sklearn\base.py", line 21, in <module>
from .utils import _IS_32BIT
File "C:\Program Files\Python\lib\site-packages\sklearn\utils\__init__.py", line 20, in <module>
from scipy.sparse import issparse
File "C:\Program Files\Python\lib\site-packages\scipy\__init__.py", line 119, in <module>
from scipy._lib._ccallback import LowLevelCallable
File "C:\Program Files\Python\lib\site-packages\scipy\_lib\_ccallback.py", line 1, in <module>
from . import _ccallback_c
ImportError: cannot import name '_ccallback_c' from 'scipy._lib' (C:\Program Files\Python\lib\site-packages\scipy\_lib\__init__.py)
I have made sure that the interpreter is correct. I have made sure that I have uninstalled older versions of python from my computer but unfortunately still no luck.
I will really appreciate it if someone can point out how to solve this problem.
Thanks
Try removing Scipy folder from C:/Users/SmithyB/AppData/Roaming/Python/Python36/site-packages/scipy
Reinstall using pip install scipy
Thanks for all your input, I couldn't have solved the problem without you guys.
I am posting how I solved the problem with the hope that it will be helpful to someone.
Since the problem was originally with using the SK-Learn library I uninstalled scikit-learn
pip uninstall scikit-learn
and then reinstalled it.
pip install scikit-learn
the error did not go away after that so I followed the suggestion of uninstalling scipy
pip uninstall scipy
and then reinstalling it.
pip install scipy
I ran a code that I had written which uses sklearn previously and it worked.
Related
I need jaxlib==0.1.67 for a project I'm working on, but I can't
downgrade. At the moment I have jaxlib==0.1.75 and my program keeps failing due to an error I can't find a solution to either. I compared all versions of the important packages to another machines versions where my programs runs with no problems and the only difference is the jaxlib version (it's still 0.1.67 on the machine where it runs). I suspect that jaxlib is the issue because the error I get when it's not 0.1.67 is the following:
from haiku import data_structures
File "/net/home/justen/.local/lib/python3.10/site-packages/haiku/data_structures.py", line 17, in <module>
from haiku._src.data_structures import to_immutable_dict
File "/net/home/justen/.local/lib/python3.10/site-packages/haiku/_src/data_structures.py", line 30, in <module>
from haiku._src import utils
File "/net/home/justen/.local/lib/python3.10/site-packages/haiku/_src/utils.py", line 24, in <module>
import jax
File "/net/home/justen/.local/lib/python3.10/site-packages/jax/__init__.py", line 108, in <module>
from .experimental.maps import soft_pmap
File "/net/home/justen/.local/lib/python3.10/site-packages/jax/experimental/maps.py", line 25, in <module>
from .. import numpy as jnp
File "/net/home/justen/.local/lib/python3.10/site-packages/jax/numpy/__init__.py", line 16, in <module>
from . import fft
File "/net/home/justen/.local/lib/python3.10/site-packages/jax/numpy/fft.py", line 17, in <module>
from jax._src.numpy.fft import (
File "/net/home/justen/.local/lib/python3.10/site-packages/jax/_src/numpy/fft.py", line 19, in <module>
from jax import lax
File "/net/home/justen/.local/lib/python3.10/site-packages/jax/lax/__init__.py", line 334, in <module>
from jax._src.lax.parallel import (
File "/net/home/justen/.local/lib/python3.10/site-packages/jax/_src/lax/parallel.py", line 36, in <module>
from jax._src.numpy import lax_numpy
File "/net/home/justen/.local/lib/python3.10/site-packages/jax/_src/numpy/lax_numpy.py", line 51, in <module>
from jax import ops
File "/net/home/justen/.local/lib/python3.10/site-packages/jax/ops/__init__.py", line 16, in <module>
from jax._src.ops.scatter import (
File "/net/home/justen/.local/lib/python3.10/site-packages/jax/_src/ops/scatter.py", line 31, in <module>
from typing import EllipsisType
ImportError: cannot import name 'EllipsisType' from 'typing' (/usr/lib/python3.10/typing.py)
haiku and typing are the same version on both machines so guess it must be jaxlib. On both machines I'm on pip==20.0.2 and in a python 3.9.9 virtualenv.
When I try to downgrade to jaxlib==0.1.67 I get:
ERROR: Could not find a version that satisfies the requirement jaxlib==0.1.67 (from versions: 0.1.75, 0.1.76, 0.3.0, 0.3.2, 0.3.5, 0.3.7, 0.3.10, 0.3.14, 0.3.15)
ERROR: No matching distribution found for jaxlib==0.1.67
I even tried pip install jaxlib==0.1.67 -f https://storage.googleapis.com/jax-releases/jax_releases.html and it doesn't work.
Has anyone experienced the same problem or maybe has a clue of what could be the issue here to help me?
Based on the path in the exception (/usr/lib/python3.10), it looks like you are using python 3.10. There are no python 3.10 wheels for jaxlib==0.1.67 (see pypi). You will have to use python 3.6-3.9.
If you think you are using python 3.9, then here's a way to clear up confusion when installing packages. Use
python3.9 -m pip install
to install packages into your python 3.9 environment. Replace python3.9 with whichever python interpreter you want to use.
The answer by #jkr is the correct answer for your question as written (how to install jaxlib 0.1.67), but I don't think it will fix the initial error you reported.
This looks like a Python 3.10 only bug that briefly existed in the JAX source code on October 5, 2021, but was fixed and never actually made it into a jax release. If you're seeing this, I suspect it means you installed/imported JAX from unreleased source. Further, installing a different version of jaxlib will not fix this error, because the code is in jax itself. If you're using jaxlib 0.1.75, you might try installing jax v0.2.7 or v0.2.8, which were released around the same time, and shouldn't contain the problematic EllipsisType import.
Another potential issue: you reported using a Python 3.9.9 virtualenv, but your traceback indicates you're executing Python 3.10, so you probably need to check your executable paths to make sure you're executing what you think you are.
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 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'm going through the API tutorial on New Coder (this one) and got the following error when I try to run the program:
RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9Traceback (most recent call last):
File "api.py", line 7, in <module>
import matplotlib.pyplot as plt
File "/home/crash/TestEnv/venv/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "/home/crash/TestEnv/venv/local/lib/python2.7/site-packages/matplotlib/colorbar.py", line 32, in <module>
import matplotlib.artist as martist
File "/home/crash/TestEnv/venv/local/lib/python2.7/site-packages/matplotlib/artist.py", line 12, in <module>
from .transforms import Bbox, IdentityTransform, TransformedBbox, \
File "/home/crash/TestEnv/venv/local/lib/python2.7/site-packages/matplotlib/transforms.py", line 39, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: numpy.core.multiarray failed to import
I know it isn't my code because I tried running it with the example code too and had the same issue. One answer I saw suggested on here was to try Numpy 1.8, but that didn't work either.
Also, all of this is set up within a virtual environment as directed so I don't think it's an issue of what I have installed elsewhere.
Installing packets from file with requirements may cause failures. I mean something like pip install -r requirements.txt
It seems to me that pip just installs packets in order without dependencies (first line from file, second line, ...).
I had same issue because of having installed numpy outside of environment and numpy after matplotlib in requirements.txt Pip compiled matplotlib with system nympy, after that it installed new numpy and nothing worked.
I just have switched strings and set matplotlib after numpy. Now it works.
Try this:
pip install numpy --upgrade
It works for me
I have been trying to install and use scikit-learn and nltk. However, I get the following error while importing anything:
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/site-packages/sklearn/init.py", line 57, in
from .base import clone
File "/usr/local/lib/python2.7/site-packages/sklearn/base.py", line 11, in
from .utils.fixes import signature
File "/usr/local/lib/python2.7/site-packages/sklearn/utils/init.py", line 10, in
from .murmurhash import murmurhash3_32
File "numpy.pxd", line 155, in init sklearn.utils.murmurhash (sklearn/utils/murmurhash.c:5029)
ValueError: numpy.dtype has the wrong size, try recompiling
I did a pip uninstall numpy followed by a pip install numpy and also a pip uninstall scikit-learn and again reinstalled it. But the error persists.
I met the same problem today. Now I have solved it.
Because I have installed numPy manually, and I use the command "pip" to install the else package.
Solve way:
find the old version of numPy.
You can import numPy and print the path of it.
delete the folder.
use pip to install again.