futuredataengineer
futuredataengineer

Reputation: 462

Mounting Google Drive to Python Colab error

Someone uploaded a folder on Google Drive and shared it with me. I installed Google Colab and opened an IPhython notebook in colab. For connecting it with Google Drive, I did:

from google.colab import drive
drive.mount('/content/gdrive')

I continued to run the code and do some imports, and at some point I need to give the path for this folder. I tried:

path = "/content/gdrive/MyDrive/the_folder/"

But when I checked on the left-hand-side, under "Files"->"gdrive"->"MyDrive", it's not even there, so no wonder it's not found when I run the code later. Did I mount it incorrectly?

Upvotes: 2

Views: 1365

Answers (1)

ans
ans

Reputation: 390

In case you want to work with a shared by someone Google Drive folder (you are not an owner of which) in Google Colab, you should, first of all, create a shortcut of this folder inside your Drive, as it exists in the Drive of its owner.

It can be done following way: right-click on this folder while in the Shared with me tab of the Google Drive and then click on the Add shortcut to Drive. This way your Drive will contain the folder (a shortcut), which was created and shared by someone else.

Then, after a regular mount procedure this folder will be accessible from Google Colab.

Upvotes: 3

Related Questions