如何在Google Colab的ipython上运行shell脚本文件

编程入门 行业动态 更新时间:2024-10-12 03:24:27
本文介绍了如何在Google Colab的ipython上运行shell脚本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道如何在Google Colab的ipython(jupyter notbook)上运行bash出售脚本文件. 我从github下载了一个深度学习代码包,并将其上传到我的google驱动器上,然后将goole驱动器安装到了Google Colab上 该代码包包括"* .py" python代码和"fn.sh"脚本文件. 通过执行脚本文件,可以执行python代码.

I'd like to know how to run a bash sell script file on ipython(jupyter notbook) at Google Colab. I downloded an Deep-learning codes package from github and upload them on my google drive and I mount the goole drive on Google Colab The code package includes'*.py' python codes and 'fn.sh' script file. By executing the script file the python codes can be executed.

我在Google Colab的ipython提示符下尝试了os.system('fn.sh')和subprocess.call('fn.sh'),但它们无法像下面那样工作.

I tried os.system('fn.sh') and subprocess.call('fn.sh') on the ipython prompt at Google Colab but they doesn't work like below.

1)

import os os.system('drive/DL/denet-master/examples/simple-cifar10.sh') 32256

2)

import subprocess subprocess.call('drive/DL/denet-master/examples/simple-cifar10.sh') OSError: [Errno 8] Exec format error: 'drive/DL/denet-master/examples/simple-cifar10.sh'

推荐答案

在Colab中,您可以使用!或%%shell调用Shell命令.

In Colab, you can invoke shell commands using either ! or %%shell.

您上面的调用将是:

!drive/DL/denet-master/examples/simple-cifar10.sh

这是一个笔记本示例:

colab.research.google/drive/1N7p0B-7QWEQ9TIWRgYLueW03uJgJLmka

更多推荐

如何在Google Colab的ipython上运行shell脚本文件

本文发布于:2023-11-23 19:11:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622569.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   文件   如何在   Google   ipython

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!