Kaggle json

I was trying to replicate the Notebook 9 and I got this message in Paperspace,

OSError                                   Traceback (most recent call last)
<ipython-input-3-84bf1621b01a> in <module>
      1 #hide
      2 from utils import *
----> 3 from kaggle import api
      4 from pandas.api.types import is_string_dtype, is_numeric_dtype, is_categorical_dtype
      5 from fastai2.tabular.all import *

/opt/conda/envs/fastai/lib/python3.7/site-packages/kaggle/__init__.py in <module>
     22 api = KaggleApi(ApiClient())
---> 23 api.authenticate()

/opt/conda/envs/fastai/lib/python3.7/site-packages/kaggle/api/kaggle_api_extended.py in authenticate(self)
    147                 raise IOError('Could not find {}. Make sure it\'s located in'
    148                               ' {}. Or use the environment method.'.format(
--> 149                                   self.config_file, self.config_dir))
    151         # Step 3: load into configuration!

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

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

and I can’t create other folders in Paperspace at the moment. I get this error:
Unexpected error while saving file: storage/course-v4/nbs/Untitled Folder [Errno 28] No space left on device: '/notebooks/storage/course-v4/nbs/Untitled Folder’

1 Like

Did you download the Kaggle API token, the Kaggle.json file with your credentials and place it in the ~/.kaggle/ directory? That should fix it.

The notebook does it in a different way by specifying the credentials directly in the notebook. Both should work.


where is the ~/.kaggle directory in Paperspace?

Just install the Kaggle api (!pip install kaggle) and download your Kaggle.json file and place it in the root directory which should already be created ‘~/.kaggle/’.

1 Like

Are you familiar with Linux? You should be able to access the filesystem using: !ls

1 Like

Jupyter allows you to conviniently upload files, I uploaded mine, switched to terminal and then mv kaggle.json ~/.kaggle/kaggle.json


I had the same issue using paperspace. What I ended up doing is uploading my kaggle.json file to my personal github branch and then on paperspace jupyter terminal, I did a git pull to download it to the paperspace. Then I copied it to the /root/kaggle directory on paperspace using the jupyter terminal. That worked, but now I’m getting another import error:

ModuleNotFoundError Traceback (most recent call last)
6 from sklearn.ensemble import RandomForestRegressor
7 from sklearn.tree import DecisionTreeRegressor
----> 8 from dtreeviz.trees import *
9 from IPython.display import Image, display_svg, SVG

ModuleNotFoundError: No module named ‘dtreeviz’


I had the same import error. In another cell I pip installed dtreeviz to get it working.

!pip install dtreeviz


I never worked with kaggle.json file, I always do:

import os

Enter you details in the corresponding fields and it works.
PS: import kaggle after running this cell


The solution is actually given in that notebook itself.

cred= ‘{username=’’, key=’’}’
cred_path = Path(’~/.kaggle/kaggle.json’).expanduser()
if not cred_path.exists():

This should create that the missing file.

1 Like

In kaggle:

I uploaded the file copied the location (which was …/input/kagglejson/kaggle.json) and put in a cell (as suggested above)

!mkdir ~/.kaggle
!cp ../input/kagglejson/kaggle.json ~/.kaggle/kaggle.json

Kaggle suggests running

!chmod 600 /root/.kaggle/kaggle.json

So the file is not viewable by others

All between the two different import cells