How to Mount Google Drive in Colab Notebook


If you want to work with files that are stored in your Google Drive with Colab Notebook, you will need to mount the drive with Colab.

In order to mount drive you will need to make use of the drive module from the goole.colab package.

Simply copy and paste the below 2 lines of python code in your Colab Notebook Code Cell and execute it.

Once you run the cell, you will see a message like below to get permit for the notebook to access your Google Drive files.

from google.colab import drive

drive.mount('/content/drive')
Permit this notebook to access your Google Drive files

Permit this notebook to access your Google Drive files?

This notebook is requesting access to your Google Drive files. Granting access to Google Drive will permit code executed in the notebook to modify files in your Google Drive. Make sure to review notebook code prior to allowing this access.

Connect to Google Drive

Once you click on "Connect to Google Drive" you will be asked to authorize certain permissions to Colab by login with your Gmail credentials.

Once done, when you click on the file icon on the left sidebar of the Colab Notebook, you should be able to see the Google drive files and folders under drive -> MyDrive.

Colab copy file path from drive folder
-

Facing issues? Have Questions? Post them here! I am happy to answer!


Author: Rakesh
Author Info:

Rakesh is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

Copyright © Code2care 2023 | Privacy Policy | About Us | Contact Us | Sitemap