Skip to content Skip to sidebar Skip to footer

Mount Google Drive In Kaggle Notebook

In google colab, I easily mount my google drive with this: from google.colab import drive drive.mount('/content/gdrive') In kaggle's notebook, however, it gives this error: KeyErr

Solution 1:

In fact, the google-colab library does not exist in the Kaggle Kernel. In this way, I use the following procedure to deal with this problem in Kaggle Kernel:

  • First, extract the ID of your desire file from google drive:

    1. In your browser, navigate to drive.google.com.

    2. Right-click on the file, and click "Get a shareable link"

      Right click get shareable link

    3. Then extract the ID of file from URL:

      enter image description here

  • Next, install gdown PyPI module using conda:

    ! conda install -y gdown

  • Finally, download the file using gdown and the intended ID:

    !gdown --id <put-the-ID>

For example:

!gdown --id 1-1wAx7b-USG0eQwIBVwVDUl3K1_1ReCt

Solution 2:

google-colab is not maintained by Google, and Colab libraries like drive.mount won't work outside of the Colab environment itself.

Solution 3:

As the stack trace suggests you have some keys missing.

  • CLOUDSDK_CONFIG

You can get this key by logging into GCP and searching for creds

To use these secretively: place this key into Kaggle Secrets Add-ons.

Post a Comment for "Mount Google Drive In Kaggle Notebook"