1

I know this has been asked several times in the past, but still can't find the answer...

This is the code

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

dataset = pd.read_csv("Data.csv")
x = dataset.iloc[:,0:3].values
y = dataset.iloc[:, 3].values

from sklearn.preprocessing import Imputer

This is the error

File "C:\Users\Martin\Desktop\Python\Udemy_Machine Learning de A a la Z (R y.Python para Data Science)\2. Data_preprocessing\Data_preprocessing.py", line 15, in from sklearn.preprocessing import Imputer

ModuleNotFoundError: No module named 'sklearn'

I'm using Spyder 4.2

After trying Carlos suggestion, now the error i get is that Pandas is not found... Is it because i change the interpreter's location?

Tom Aranda
  • 5,919
  • 11
  • 35
  • 51
Martin
  • 21
  • 3
  • Do you actually have sklearn installed? – Jared Smith Dec 17 '20 at 23:55
  • (*Spyder maintainer here*) Did you install Spyder with our installer for Windows or Mac? – Carlos Cordoba Dec 17 '20 at 23:57
  • https://stackoverflow.com/questions/46113732/modulenotfounderror-no-module-named-sklearn – AndrewQ Dec 17 '20 at 23:58
  • I tried installing sklearn using "pip3 install -U scikit-learn" on spyder. Did not work – Martin Dec 18 '20 at 00:02
  • Hello Carlos, yes, with spyder's installer for Windows – Martin Dec 18 '20 at 00:03
  • Ok, I imagined. Unfortunately, our installers come with a limited set of packages. To use `scikit-learn` you need to download [Miniconda](https://docs.conda.io/en/latest/miniconda.html) (the Python 3.8 version is fine); then [create an environment](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands) with conda; and finally connect it to Spyder using [these instructions](http://docs.spyder-ide.org/current/faq.html#using-existing-environment). – Carlos Cordoba Dec 18 '20 at 00:15
  • We're very sorry that this process is quite convoluted and hard to do. We'll try to simplify it next year. – Carlos Cordoba Dec 18 '20 at 00:17
  • Ok, thank you Carlos. When creating an enviroment, which option should i choose? with a specific version of Python, with a specific package, with a specific version of a package? Thank you for your help! – Martin Dec 18 '20 at 00:59
  • You can use this command to create your environment: `conda create -n myenv python=3.8 scikit-learn`. That will install Python 3.8 and scikit-learn at the same time. – Carlos Cordoba Dec 18 '20 at 01:14

1 Answers1

0
pip install scikit-learn

Try the above comment and install.

S.B
  • 13,077
  • 10
  • 22
  • 49