Chapter 9 error


I get this error when running the second code cell:

OSError: Could not find kaggle.json. Make sure it’s located in /root/.kaggle. Or use the environment method.

How can I resolve this?

Thank you!

Hi Sang
Did you download the json from Kaggle?
Regards Conwyn

Hi Conwyn,
Yes, but I am not sure where to place the kaggle.json file. I don’t know how to create or place where the .kaggle directory is supposed to be.

Hi Sang
Create a directory
!mkdir /root/.kaggle
Look for existing file
!find / -name kaggle.json -print
Copy to new directory
!cp /where/you/found/it/kaggle.json /root/.kaggle

Regards Conwyn

Hi Conwyn,

For some reason I am unable to make the .kaggle directory as far as I can see. I instead get a directory called root.kaggle:

Hi Sang
Are you following pages 284/285 of the book.
Can you try setting an environment variable to point to the directory of the json file (Easy way to use Kaggle datasets in Google Colab | Data Science and Machine Learning)
Regards Conwyn

import os
os.environ['KAGGLE_CONFIG_DIR'] = "/content/drive/My Drive/fastai-v3/.kaggle/" # put path for wherever you put it

Hi Sang

Can you try (roughly from the book)

%matplotlib inline
%reload_ext autoreload

!pip install -Uqq fastbook
import fastbook
from fastai import *
from import *

!pip install kaggle

!mkdir ~/.kaggle

!cp “/content/gdrive/My Drive/.kaggle/kaggle.json” ~/.kaggle

!ls -al ~/.kaggle

cred_path = Path(’~/.kaggle/kaggle.json’).expanduser()

if not cred_path.exists():

path = URLs.path(‘bluebook’)

!mkdir /root/.fastai/archive
!mkdir /root/.fastai/archive/bluebook

if not path.exists():

ls -al /root/.fastai/archive/bluebook

Hi Conwyn, thanks again for the suggestions. I tried running the code but got this error:

Hi Sang

Sorry !ls. ! passes the command to the unix shell.

Regards Conwyn