Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google colab changing directory

Tags:

I can't change my directory in Google colab. when I type cd it gives output like this '/content' I tried to change the directory using import os os.chdir("drive")

but it shows error No such file or directory: 'drive' . How to get rid of this?

like image 396
Mushahid Shamim Avatar asked May 23 '18 03:05

Mushahid Shamim


People also ask

How do I change directory in Python?

To change the current working directory in Python, use the chdir() method. The method accepts one argument, the path to the directory to which you want to change. The path argument can be absolute or relative.


1 Answers

If you want to change directory from google colab into google drive, connect to google drive first.

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

It will ask for authentication key that will be can be obtained when signing in to your google drive

Change to the google drive directory.

%cd /content/drive/My\ Drive/

For verifying: !pwd

Your current directory is /content/drive/My Drive/

like image 167
Edward Edberg Avatar answered Sep 18 '22 16:09

Edward Edberg