[英]mount google drive in kaggle notebook
In google colab, I easily mount my google drive with this:在 google colab 中,我很容易用这个挂载我的谷歌驱动器:
from google.colab import drive
drive.mount('/content/gdrive')
In kaggle's notebook, however, it gives this error:然而,在 kaggle 的笔记本中,它给出了这个错误:
KeyError Traceback (most recent call last)
<ipython-input-14-2b128295b616> in <module>
2 # !pip install google-colab
3 from google.colab import drive
----> 4 drive.mount('/content/gdrive')
5 # Set your own project id here
6 # PROJECT_ID = 'your-google-cloud-project'
/opt/conda/lib/python3.6/site-packages/google/colab/drive.py in mount(mountpoint, force_remount, timeout_ms)
80 return
81
---> 82 env = _env()
83 home = env.home
84 root_dir = env.root_dir
/opt/conda/lib/python3.6/site-packages/google/colab/drive.py in _env()
41 home = _os.environ['HOME']
42 root_dir = _os.path.realpath(
---> 43 _os.path.join(_os.environ['CLOUDSDK_CONFIG'], '../..'))
44 inet_family = 'IPV4_ONLY'
45 dev = '/dev/fuse'
/opt/conda/lib/python3.6/os.py in __getitem__(self, key)
667 except KeyError:
668 # raise KeyError with the original key value
--> 669 raise KeyError(key) from None
670 return self.decodevalue(value)
671
KeyError: 'CLOUDSDK_CONFIG'
This is my setup in kaggle notebook (also tested this , did not work):这是我在 kaggle 笔记本中的设置(也对此进行了测试,没有用):
!pip install google-colab # I don't know if this is the correct package
from google.colab import drive
drive.mount('/content/gdrive')
In fact, the google-colab
library does not exist in the Kaggle Kernel.实际上,Kaggle 内核中并不存在
google-colab
库。 In this way, I use the following procedure to deal with this problem in Kaggle Kernel:这样,我在 Kaggle Kernel 中使用下面的过程来处理这个问题:
First, extract the ID of your desire file from google drive:首先,从谷歌驱动器中提取您想要的文件的 ID:
Next, install gdown
PyPI module using conda
:接下来,使用
conda
安装gdown
PyPI 模块:
! conda install -y gdown
Finally, download the file using gdown
and the intended ID:最后,使用
gdown
和预期的 ID 下载文件:
!gdown --id <put-the-ID>
For example:例如:
!gdown --id 1-1wAx7b-USG0eQwIBVwVDUl3K1_1ReCt
google-colab
不由 Google 维护,并且像drive.mount
这样的 Colab 库无法在 Colab 环境本身之外运行。
As the stack trace suggests you have some keys missing.正如堆栈跟踪所暗示的,您缺少一些键。
You can get this key by logging into GCP and searching for creds您可以通过登录 GCP 并搜索凭据来获取此密钥
To use these secretively: place this key into Kaggle Secrets Add-ons.要秘密使用这些:将此密钥放入 Kaggle Secrets 附加组件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.