Can't find kaggle.json file in google colab

后端 未结 4 2311
不思量自难忘°
不思量自难忘° 2021-02-18 23:28

I\'m trying to download the kaggle imagenet object localization challenge data into google colab so that I can use it to train my model. Kaggle uses an API for easy and fast acc

相关标签:
4条回答
  • 2021-02-18 23:36

    As the error said, you need to put kaggle.json in the right place.

    Try:

    !mv .kaggle /root/
    

    Then run your code again.

    0 讨论(0)
  • 2021-02-18 23:36

    You can find the JSON file that you need to place form Kaggle's portal itself. Just click 'Create New API Token' and it will give you a JSON file that needs to be placed.

    0 讨论(0)
  • 2021-02-18 23:38

    According to kaggle api documentation the location where credentials json is looking for is ~/.kaggle/kaggle.json as google colab environment is Linux based. In your snippet you try to config path parameter, but it is not used to looking for credential json:

    - path: Folder where file(s) will be downloaded, defaults to current working directory

    So the full working snippet for google colab environment would be:

    !mkdir ~/.kaggle
    !touch ~/.kaggle/kaggle.json
    
    api_token = {"username":"username","key":"api-key"}
    
    import json
    
    with open('/root/.kaggle/kaggle.json', 'w') as file:
        json.dump(api_token, file)
    
    !chmod 600 ~/.kaggle/kaggle.json
    

    And then some api call like

    !kaggle datasets download -d datamunge/sign-language-mnist
    
    0 讨论(0)
  • 2021-02-18 23:56

    In case you are a windows user, move your kaggle.json into .kaggle folder, that you are able to find it in your system root (which is in your username folder).

    0 讨论(0)
提交回复
热议问题