15

I use Google Colab extensively. In order to get an easy access to files in my Google drive, I mount the drive to the file system of the virtual machine that runs Colab. Like that:

from google.colab import drive as cdrive
cdrive.mount('/content/gdrive')
% cd /content/gdrive/'My Drive'/'Colab Notebooks'/my_directory

Colab sessin. Each time

In the beginning of each session, I need to give a permission to access my drive. In order to do that, I need to press 'Allow', copy a one-time-password and paste it to a dedicated text area. It's a bit tedious.

Is there a better way? can I give a permanent permission based on my machine? any other ideas?

Ori Mosenzon
  • 511
  • 2
  • 9

1 Answers1

3

At this moment, we can access google drive with the Mount Drive button on the left menu bar.

enter image description here

Confirm the access Google Drive action.

enter image description here

Then it will be mounted to your Colab notebook.

enter image description here

huy
  • 1,648
  • 3
  • 14
  • 40
  • Thanks, any luck with doing this in python code rather than manually? – Silviu Jun 01 '21 at 12:14
  • @Silviu I don't find any better solution. The code on the question is the simplest way to connect to Google Drive but it requires some authenticate steps. – huy Jun 02 '21 at 11:38