Google Colab: How can I mount a particular folder instead of mounting root folder?

十年热恋 提交于 2020-06-11 18:09:30

问题


I am able to mount Google drive using the code below:

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

But the above mounts the Root folder enabling all file access within the drive.

I want a particular folder in Google drive to to be mounted (for example just the dataset folder). How can I achieve that?


回答1:


It's not possible to mount a subfolder, only top-level Drive. You can mount Drive in some out-of-the-way place and then symlink the folder you want someplace more central, e.g.:

from google.colab import drive
drive.mount('/gdrive')
!ln -s "/gdrive/My Drive/theFolder" "/content/theFolder"



回答2:


  1. Mount at /content/drive

     from google.colab import drive
     drive.mount('/content/drive')
    
  2. Change directory using cd command

     cd 'drive/My Drive'
    



来源:https://stackoverflow.com/questions/53183525/google-colab-how-can-i-mount-a-particular-folder-instead-of-mounting-root-folde

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!