Skip to content

Instantly share code, notes, and snippets.

@INF800
Created February 20, 2021 09:33
Show Gist options
  • Save INF800/8c79f8502d750c60f17ba35f4a46f0ff to your computer and use it in GitHub Desktop.
Save INF800/8c79f8502d750c60f17ba35f4a46f0ff to your computer and use it in GitHub Desktop.

I wanted to find a different method that didn't require me to read the json file or to have to upload it to root while using Colab. I instead wanted to just store the json in my drive somewhere and let the kaggle cli know where it is.

As it turns out, there's a way to do that, which is set the environment variable KAGGLE_CONFIG_DIR

If you don't have the json file yet, check the docs for how to get that: link Then upload it to your drive. Mine happens to be at /content/drive/My Drive/fastai-v3/.kaggle/kaggle.json. (ayyy shoutout to the FastAI courses 👌 ) Now in colab you can just run:

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

INF800 commented Feb 20, 2021

"""
setup kaggle
"""

import os, shutil

os.makedirs('.kaggle', exist_ok=True)
shutil.move('kaggle.json', '.kaggle/kaggle.json')

os.environ['KAGGLE_CONFIG_DIR'] = '.kaggle/'

!kaggle datasets download -d mission-ai/crimeucfdataset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment