当前位置:网站首页>Geogle Colab笔记1--运行Geogle云端硬盘上的.py文件
Geogle Colab笔记1--运行Geogle云端硬盘上的.py文件
2022-07-25 15:28:00 【whut_L】
目录
一--Geogle Colab获得google drive的授权
二--指定Google Drive云端硬盘的根目录,名为drive
一--Geogle Colab获得google drive的授权
操作:新建一个Colab ipynb文件,输入以下代码:
!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}结果:弹出一个链接,点解链接获得Code,并输入至白框内,重复操作两次。



二--指定Google Drive云端硬盘的根目录,名为drive
!mkdir -p drive
!google-drive-ocamlfuse drive # 此时colab中出现drive的文件夹,里面就是你的google drive的根目录文件三--复制需运行.py文件所在文件夹的绝对路径

分析:上图中,本人将运行的.py文件是ntu_gendata.py(程序摘自CVPR 2020一篇Oral文章),则复制生成的路径为/content/drive/Shift-GCN-master/data_gen(注:不是ntu_gendata.py的路径,而是它所在文件夹即data_gen的路径),根据复制的路径执行以下代码:
cd /content/drive/Shift-GCN-master/data_gen四--运行需执行的.py文件
在Colab新代码框内执行以下代码:
!python ntu_gendata.py注:!为英文字母。
分析:代码运行后生成的文件,将自动保存在Geogle云端硬盘中(根据.py文件设定的路径)。
五--参考
边栏推荐
- C # fine sorting knowledge points 10 generic (recommended Collection)
- C # carefully sorting out key points of knowledge 11 entrustment and events (recommended Collection)
- C#精挑整理知识要点12 异常处理(建议收藏)
- JVM-垃圾收集器详解
- Week303 of leetcode
- 从 join on 和 where 执行顺序认识T-sql查询执行顺序
- Delayed loading source code analysis:
- window系统黑窗口redis报错20Creating Server TCP listening socket *:6379: listen: Unknown error19-07-28
- C # fine sorting knowledge points 9 Set 2 (recommended Collection)
- 图论及概念
猜你喜欢
随机推荐
Graph theory and concept
Args parameter parsing
2021上海市赛-B-排序后dp
UIDocumentInteractionController UIDocumentPickerViewController
《图书馆管理系统——“借书还书”模块》项目研发阶段性总结
2019浙江省赛C-错排问题,贪心
matlab 如何保存所有运行后的数据
matlab 优化工具 manopt 安装
SVD奇异值分解推导及应用与信号恢复
2016CCPC网络选拔赛C-换根dp好题
How to solve the problem of scanf compilation error in Visual Studio
MATLAB 如何生产随机复序列
记一次redis超时
Once spark reported an error: failed to allocate a page (67108864 bytes), try again
4PAM在高斯信道与瑞利信道下的基带仿真系统实验
Example of password strength verification
How to finally generate a file from saveastextfile in spark
Remember that spark foreachpartition once led to oom
Promise object and macro task, micro task
ios 面试题









