【问题标题】:Problem: Google Colab import libraries and authorization to use google drive takes too long?问题:Google Colab 导入库和授权使用 google drive 需要太长时间?
【发布时间】:2018-08-03 11:29:44
【问题描述】:

我在 google colab 中执行这部分代码,以授权我访问我的驱动器文件夹

!apt-get install -y -qq software-properties-common python-software-properties module-init-tools
!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null 
!apt-get update -qq 2>&1 > /dev/null
!apt-get -y install -qq google-drive-ocamlfuse fuse
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}

但是当涉及到从给定的url复制和粘贴验证码的部分时,执行并没有结束,所以继续下一个块。有什么问题?即使我仍然处于连接状态。

【问题讨论】:

    标签: directory authorization google-colaboratory drive


    【解决方案1】:

    按照this 教程,过去几天我一直在使用它,对我有用的是:

    1.- 在单个单元格中运行:

    from google.colab import auth auth.authenticate_user()

    2.- 点击链接,复制并粘贴生成的密码

    3.- 在另一个单元格中运行:

    from oauth2client.client import GoogleCredentials creds = GoogleCredentials.get_application_default() import getpass prompt = !google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL vcode = getpass.getpass(prompt[0] + '\n\nEnter verification code: ') !echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}

    4.- 再次点击链接,复制并粘贴新生成的密码

    5.- 继续安装您的驱动器并处理您的文件!

    【讨论】:

    • 当我复制并粘贴生成的密码时......单元格“当前正在执行..”永远不会结束执行
    • 这是在黑暗中拍摄的,但也许是广告拦截?还是浏览器?我用 Chrome
    • 我也试过 linux 上的 Chrome(没有任何附加组件),但还是一样
    • 对不起@TassosK,我只有我自己的经验和我的同事。希望你能找到解决办法!
    【解决方案2】:

    这似乎是其他人在此处讨论的问题:https://github.com/googlecolab/colabtools/issues/231

    您是否还在 JS 控制台上看到任何 400 或错误?

    【讨论】:

    • 其实我也是其中一员……但还是没有任何令人信服的答案
    【解决方案3】:

    最近我做了一个新的努力,似乎可以工作,为了将你的驱动器安装到 colab-notebook,请改用这些行,

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

    运行它,

    点击链接接受并复制粘贴给定的代码,点击回车完成!与我之前询问的方式相比,它仍然无法正常工作。

    【讨论】:

      【解决方案4】:

      粘贴生成的代码后,按键盘上的 Enter。它会继续缓冲,直到你这样做。

      【讨论】:

      • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
      猜你喜欢
      • 2015-01-22
      • 2017-10-17
      • 1970-01-01
      • 2020-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-15
      • 2013-09-06
      相关资源
      最近更新 更多