Installing sklearn on AWS deeplearning AMI

Garglesoap Source

I'm trying to install sklearn onm an AWS DeepLearning AMI, with Conda and an assortment of backends pre-installed. I'm following ScikitLearn's website instructions:

$ conda install -c anaconda scikit-learn 
$ source activate python3
$ jupyter notebook

In Jupyter notebook:

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

#Scaling the data
from sklearn.preprocessing import MinMaxScaler

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-884b8a303194> in <module>()
     12 
     13 #Scaling the data
---> 14 from sklearn.preprocessing import MinMaxScaler
     15 sc = MinMaxScaler()                           #scaling using normalisation
     16 training_set1 = sc.fit_transform(training_set1)

ModuleNotFoundError: No module named 'sklearn'
pythonamazon-web-servicesscikit-learn

Answers

answered 3 months ago Neal C #1

You need to start the virtual environment first "source activate python3", then install scikit-learn. Without activating the virtual environment, you are installing into the base python and not into the virtual environment.

Cheers

answered 1 day ago Reza SA #2

And in case anybody didn't know how to install packages in each conda environment, it is (as in this case my environment of choice was Tensorflow in Python 3.6) here is the command I used my mac bash, and in my EC2 environment:

[email protected] ***.***.**.***:~$ source activate tensorflow_p36

and then:

[email protected] ***.***.**.***:~$ conda install -c anaconda scikit-learn

comments powered by Disqus