在谷歌C​​olab上安装谷歌硬盘

时间:2018-05-04 06:14:25

标签: google-colaboratory

我按照谷歌colab上的这个媒体教程中给出的步骤,然后尝试克隆git存储库,但我无法在驱动器中的任何位置看到存储库。

下面的图片是我使用的代码片段,它与Medium教程中的代码片段完全相同:
The code snippet I used which is exactly the same as that from the Medium tutorial

3 个答案:

答案 0 :(得分:1)

要在Google Colab上安装Google驱动器,只需使用以下命令:

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

这将需要身份验证过程。做任何需要的事情(打开链接并复制密钥)

现在,您已经将Google驱动器安装在Google Colab计算机的/content/drive/目录中。

要克隆git存储库,请首先在/content/drive/中将当前目录设置为路径,然后再克隆git存储库。如下所示:

path_clone = "/content/drive/my_project"
%cd path_clone
!git clone <Git project URL address>

请确保在执行更改目录命令时使用%!无效。

现在,您将在Google云端硬盘(也已连接到您的Google Colab运行时计算机)的my_projects文件夹中拥有克隆的Git项目

答案 1 :(得分:0)

调整git克隆的路径。 尝试将驱动器文件夹添加到路径

import os
os.chdir("drive")

答案 2 :(得分:0)

只需cd drive(不包含!)或%cd drive

请参见cd vs !cd vs %cd in IPython

相关问题