You may try to import scikit-learn, but you may find this problem as shown below:
ModuleNotFoundError: No module named 'sklearn'
So, you’re rocking Anaconda and Python 3.6.1, thinking life’s good. But then, despite Googling like a pro, nada.
You throw in the Hail Mary: conda install scikit-learn
. But guess what? No magic fix. Now you’re playing detective, asking Anaconda, “Yo, where did you stash scikit-learn?”
Peek into your Python library, expecting to see sklearn chilling with NumPy and SciPy, but nope, it’s the lonely kid in the corner.
Feeling a bit like Sherlock without a Watson, you’re here seeking guidance. Python packages, especially via Anaconda, can be a maze, especially for a rookie.
Let’s learn how to fix solve this problem and make sklearn working as you want.
Solution 1: The Pip Power
Installing packages is a breeze, even if you’re an Anaconda user. Just fire up pip. It doesn’t matter if you are using Anaconda, just give pip a try:
pip install -U scikit-learn scipy matplotlib
That line should smoothly get your package installed. Now, if you’re rocking Python 3.x, no worries. Just tweak it a bit with pip3:
pip3 install -U scikit-learn scipy matplotlib
Solution 2: Go with conda
Alright, if you’re having trouble getting things set up, here are a couple of ways you can tackle it:
If you’re a fan of conda and your system meets the requirements (Python version >= 2.7 or >= 3.4, NumPy >= 1.8.2, and SciPy >= 0.13.3), this should work like a charm:
conda install scikit-learn
If you want to get a bit fancier, throw in the channel like this:
conda install -c anaconda scikit-learn
And let’s say you’re working in a space called “ML,” just run either of these:
conda install -n ML scikit-learn
or
conda install -n ML -c anaconda scikit-learn
I hope you try both of these options to solve your problem.