Google Collaboratory在授权期间不显示链接

2024-06-16 16:10:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我创建了一个新的Colaboratory笔记本,想简单地验证一下自己是否可以访问驱动器上的文件。但是当我运行下面的脚本时

from google.colab import auth
auth.authenticate_user()
from oauth2client.client import GoogleCredentials
creds = GoogleCredentials.get_application_default()
import getpass
!google-drive-ocamlfuse --headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL
vcode = getpass.getpass()
!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}

我唯一能看到的就是文本输入,没有任何链接,什么都没有。在

enter image description here

当我只输入任何内容时,就会收到/bin/sh: 1: google-drive-ocamlfuse: not found。最近这种事经常发生在我身上,我做错了什么?在


Tags: fromimportclientauthidsecretgoogledrive
1条回答
网友
1楼 · 发布于 2024-06-16 16:10:21

编辑:自从最初回答这个问题以来,Google添加了内置的Drive FUSE支持。您可以使用更紧凑的代码段装入驱动器文件:

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

使用此实用程序安装和装载驱动器文件的完整示例如下:

https://colab.research.google.com/drive/1srw_HFWQ2SMgmWIawucXfusGzrj1_U0q

相关问题 更多 >