如何在Google Colab的ipython上运行shell脚本文件 [英] How to run shell script file on ipython at Google Colab

查看:1550
本文介绍了如何在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

这是一个笔记本示例:

https://colab.research.google.com/drive/1N7p0B-7QWEQ9TIWRgYLueW03uJgJLmka

这篇关于如何在Google Colab的ipython上运行shell脚本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆