我像这样在 Colab 中安装我的 Google Drive:
from google.colab import drive
drive.mount('/content/drive')
现在,当我想解压缩位于文件夹“drive/MyDrive/”中的文件“tommuddi.zip”时
我必须使用“drive/MyDrive/tommuddi.zip”访问它,这很麻烦:
from zipfile import ZipFile
file_name = 'drive/MyDrive/tommuddi.zip'
with ZipFile(file_name, 'r') as zip:
zip.extractall()
print('Done')
相反,我想访问的是使用
file_name = 'tommuddi.zip'
我怎样才能让 Colab 假设“MyDrive”是根目录以便上述工作?
当我尝试这个...
from google.colab import drive
drive.mount('/content/drive/MyDrive')
...它抛出错误
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-25-c0fc2c3766a0> in <module>()
1 from google.colab import drive
----> 2 drive.mount('/content/drive/MyDrive')
1 frames
/usr/local/lib/python3.7/dist-packages/google/colab/drive.py in _mount(mountpoint, force_remount, timeout_ms, use_metadata_server, ephemeral)
285 ': timeout during initial read of root folder; for more info: '
286 'https://research.google.com/colaboratory/faq.html#drive-timeout')
--> 287 raise ValueError('mount failed' + extra_reason)
288 elif case == 2:
289 # Not already authorized, so do the authorization dance.
ValueError: mount failed
谢谢!