1

I am pretty new to Python and am trying to import train_test_split from sklearn.model_selection for a machine learning project, using the code:

26:reviews = [] 27:with open(file_name) as f: 28: for line in f: 29: review = json.loads(line) 30: reviews.append(Review(review['reviewText'], review['overall'])) 31:from sklearn.model_selection import train_test_split 32:training,test = train_test_split(reviews, test_size = 0.4, random_state=45) 

I am getting the error

"C:\Users\jacks\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sklearn\__init__.py", line 79, in <module> from . import __check_build # noqa: F401 ImportError: cannot import name '__check_build' from partially initialized module 'sklearn' (most likely due to a circular import) 

I have tried googling around and have not found a reason for the error and I have downloaded the newest version of sklearn. I do not understand why the library is not importing correctly, nor why the error is for "__check_build" when I do not have anything in the code with that name. I am completely stuck. Does anyone know how to fix this problem?

2 Answers 2

1

You need to install scipy, too:

pip install scipy 

and restart the powershell

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the help, but I am not sure how to restart the power shell. Do you mean restart my computer from the Powershell? If not then how might one restart the Powershell?
No i mean just close it and open it again if you start your programms from powershell/command-line. If you use an idle, just restart the idle.
0

I have installed scikit-learn with the following in the terminal:

pip install scikit-learn 

If it doesn't work I would recommend trying the following, going through anaconda:

conda install -c anaconda scikit-learn 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.