question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

kaggle command fails with google colaboratory

See original GitHub issue

Executing the following command will result in an error. “kaggle.json” is right under google drive. What is the cause?

https://colab.research.google.com/drive/1BhbII5rQTqfxLK0aYusfHReWJpNSm7XD

!pip install kaggle

Collecting kaggle : Successfully installed Unidecode-1.0.22 kaggle-1.4.7.1 python-slugify-1.2.6

from googleapiclient.discovery import build import io, os from googleapiclient.http import MediaIoBaseDownload from google.colab import auth auth.authenticate_user() drive_service = build('drive', 'v3') results = drive_service.files().list(q="name = 'kaggle.json'", fields="files(id)").execute() kaggle_api_key = results.get('files', []) filename = "~/.kaggle/kaggle.json" os.makedirs(os.path.dirname(filename), exist_ok=True) request = drive_service.files().get_media(fileId=kaggle_api_key[0]['id']) fh = io.FileIO(filename, 'wb') downloader = MediaIoBaseDownload(fh, request) done = False while done is False: status, done = downloader.next_chunk() print("Download %d%%." % int(status.progress() * 100)) os.chmod(filename, 600)

Download 100%

!kaggle competitions list

Traceback (most recent call last): File “/usr/local/bin/kaggle”, line 7, in <module> from kaggle.cli import main File “/usr/local/lib/python3.6/dist-packages/kaggle/init.py”, line 23, in <module> api.authenticate() File “/usr/local/lib/python3.6/dist-packages/kaggle/api/kaggle_api_extended.py”, line 110, in authenticate self._load_config(config_data) File “/usr/local/lib/python3.6/dist-packages/kaggle/api/kaggle_api_extended.py”, line 149, in _load_config raise ValueError(‘Error: Missing %s in configuration.’ % item) ValueError: Error: Missing username in configuration.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9

github_iconTop GitHub Comments

17reactions
corrieanncommented, Sep 20, 2018

Can you try changing filename above to “/root/.kaggle/kaggle.json”?

https://colab.research.google.com/gist/corrieann/7b1e460d3381bf058627bdaa64840122/kaggle-api.ipynb

13reactions
amartya-kcommented, Sep 19, 2018

It’s because the current directory is changed. Use the code below and run the cell: !mkdir ~/.kaggle !cp /content/.kaggle/kaggle.json ~/.kaggle/kaggle.json

And also you can goto the parent directory by using the command cd .. In colab by default we get ‘\contents’ as the current working directory. I hope this resolves your issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error while importing Kaggle dataset on Colab - Stack Overflow
It suddenly stopped working here as well. Apparently, the kaggle api was not searching the kaggle.json file in the correct place.
Read more >
Easiest way to download kaggle data in Google Colab
Please follow the steps below to download and use kaggle data within Google Colab: 1. Go to your account, Scroll to API section...
Read more >
Easy way to use Kaggle datasets in Google Colab
A quick guide to use Kaggle datasets inside Google Colab ... Report. The error is due to the single quote at the end...
Read more >
Issues for connecting kaggle from Colab | Data Science and ...
Hi,. i'm trying to run some simple code for deep learning image classifier and Im having issues with the kaggle - Colab connection...
Read more >
Google Colab - Too many requests error - Kaggle
It's the error with the kaggle api. You're going to have to upgrade the kaggle api to a new version so that it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found