What This article is an article that solves the error that occurred when importing scikit-learn.
Problem I got the following error when running the program below
sklearn.py
from sklearn import datasets
import numpy as np
#Load Iris dataset
iris = datasets.load_iris()
When I run this code, I get an error if I can't read dataset
from sklearn
on the bottom line.
File "sklearn.py", line 1, in <module>
from sklearn import datasets
File "/Users/apple/python/sklearn.py", line 1, in <module>
from sklearn import datasets
ImportError: cannot import name 'datasets' from partially initialized module 'sklearn' (most likely due to a circular import) (/Users/apple/python/sklearn.py)
Solution I solved it by changing the file name to something other than sklearn. It seems that it was imported itself because the file name is sklearn.
Detail I ran the following two lines to check where the file was read from
import sklearn
print(sklearn.__file__)
I was reading myself lol
/Users/apple/sklearn.py
So I changed the file name and it worked
Recommended Posts