Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

CDSW - ModuleNotFoundError: No module named 'sklearn'

avatar
New Contributor

hi
a newbie question...
i'm trying to follow the guide here (using CDSW 1.7) : https://www.cloudera.com/tutorials/building-a-linear-regression-model-for-predicting-house-prices.ht...

when i add the following 

 

import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.datasets import load_boston
from sklearn.metrics import mean_squared_error, r2_score

 

 

i get the ModuleNotFoundError :

ModuleNotFoundError: No module named 'sklearn'
ModuleNotFoundError Traceback (most recent call last) in engine ----> 1 from sklearn.model_selection import train_test_split ModuleNotFoundError: No module named 'sklearn'

 how can i solve this?

thanks

1 REPLY 1

avatar
Master Collaborator

You can do this:

 

!pip3 install sklearn

 

This will install the needed package. Note that ! is a magic command that executes the command not in your Python session but in the underlying OS environment.