I am trying to import sklearn library by writing code like from sklearn.preprocessing import MinMaxScaler but it kept showing same error.
I tried uninstalling and reinstalling but no change. Command prompt is also giving same error. Recently I installed some python libraries but that never affected my enviroment.
I also tried running the code in jupyter notebook. When I tried to import numpy like import numpy as np, it ran successfully. So the problem is only with sklearn.
Also, I have worked with sklearn before but have never seen such an error.
You have to read into the error message. For me sklearn was importing something from scipy which uses the outdated np.int, so updating scipy solved the issue for me.
Related
I'm having this issue the past couple of days that is preventing me from getting into my project. So, I have installed statmodels and whenever I type "pip list" in the VS Code Terminal I can clearly see that statsmodels 0.12.2 is installed.
My issue is that on the line that I try to import the library.
from statsmodels.tsa.seasonal import seasonal_decompose
This error pops up:
Unable to import 'statsmodels.tsa.seasonal'pylint(import-error)
Any ideas on how to fix this are highly appreciated!
I installed the package sentence_transformers via conda. It was successful; however, I cannot load them in jupyter notebook. I kept receiving the error as below. I have already upgraded all the relevant packages (sklearn, scipy, etc.) and I still receive the error.
from sentence_transformers import SentenceTransformer
ImportError: cannot import name 'is_sklearn_available' from 'transformers.data' (/Users/KK/opt/anaconda3/lib/python3.7/site-packages/transformers/data/__init__.py)
Any suggestions would be greatly appreciated.
I have faced this issue too. In my case, after restarting the jupyter kernel it worked without problems.
In my case, first I installed transformers 3.4.0, but had to downgrade to 3.1.0 due to a TF 2.1 compatibility issue. I downgraded without restarting the kernel and I got the same error message. After kernel restart, everything worked fine.
I faced this error as well. My mistake was that I was trying to import is_sklearn_available from transformers/data/init.py when I should have been importing it from transformers/file_utils.py
Please check your init.py files for a better picture.
I'm facing error whenever I import any Tree module from sklearn. Sample code below
from sklearn.ensemble import ExtraTreesRegressor
model = ExtraTreesRegressor()
model.fit(X,y)
The first time I run the code I get this error -
ImportError: cannot import name 'LatentDirichletAllocation' from 'sklearn.decomposition._online_lda' (C:\Users\lenovo\Anaconda3\lib\site-packages\sklearn\decomposition_online_lda.cp37-win_amd64.pyd)
After that, whenever I run the same code, I get the following error -
AttributeError: type object 'sklearn.tree.criterion.array' has no attribute 'reducecython'
The same code worked well before but suddenly it has stopped working for me
I've tried uninstalling and re-installing scikit-learn as well. Any help would be appreciated. Thanks :)
I think this might be a problem with conda install sklearn version 0.22 as questioned in this issues.
Try pip install -U scikit-learn
Update the scikit-learn, most precisely version 0.22.1
I am trying to run some code that requires importing NumPy and SciPy (I'm using Python 3.4), but I keep getting the following message (my OS is Windows):
import numpy as np # used for linear algebra
ImportError: No module named 'numpy'
I have already downloaded NumPy but I don't know how to set it up correctly. Is there any way to fix this? I've been having this error for a while already.
Update: I found the solution. Apparently I had already downloaded both Anaconda (a distribution of Python) and Python, so I deleted both of them and installed back Anaconda, rebooted the computer and now everything works perfectly (can use NumPy and SciPy).
ImportError: cannot import name _hierarchy
I have updated all the related packages using pip. There were no errors with updating pandas, numpy, scipy and scikit-learn. Still I keep getting this wierd error on executing this command
from scipy.cluster.vq import kmeans,vq
I am using 0.15 version. Really stuck here :(