I have been dealing with this much too long. I am using a MacBook Pro. This suddenly started happening when running Jupyter. I could not fix it. I completely uninstalled anaconda (which was using Python3.8) then completely uninstalled Python3.9. I installed Python3.96. Then went back to basics and reinstalled numpy, pandas, sklearn. Everything seems to be there in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages
This command fails in Idle and gives the error in the title of my question.
from sklearn.model_selection import train_test_split
It does not give the error in Mac’s Terminal
The search path for Idle looks correct.
Source: Python Questions