Chapter 9 error with kaggle and dtreeviz

I’m trying to follow chapter 9.
I’m using SageMaker and following error: (after installing kaggle with !pip install kaggle

ModuleNotFoundError Traceback (most recent call last)
in ()
1 #hide
2 from fastbook import *
----> 3 from kaggle import api
4 from pandas.api.types import is_string_dtype, is_numeric_dtype, is_categorical_dtype
5 from fastai.tabular.all import *

ModuleNotFoundError: No module named ‘kaggle’

Did you resolve this? I am having the same problem…scott

Yes. It is a matter of installing modules in the right environment

Hi there Joan,

Can you elaborate on your solution?

I managed to get this working by modifying the cloudformation template used to create the notebook instance. I updated the following lines:

In the OnCreate section from:

 pip install fastbook sagemaker


pip install fastbook sagemaker kaggle waterfallcharts treeinterpreter dtreeviz

And in the “OnStart” section from:

pip install fastai fastcore sagemaker --upgrade


pip install fastai fastcore sagemaker kaggle waterfallcharts treeinterpreter dtreeviz --upgrade

Hope that helps someone who runs into this in the future :slight_smile:

Kaggle and dtreeviz both seem to fail to install using the notebook pip install command.

These are the steps I followed to resolve:

Run these commands in the notebook to determine the environment:

import sys

Copy the output, this is the path to your environment. In my case:


Open a terminal from the Jupyter Notebook main index screen.

Install kaggle and dtreeviz as needed:

/home/ec2-user/SageMaker/.env/fastai/bin/python -m pip install kaggle dtreeviz