我想知道如何在Google Colab上运行ipython(jupyter notbook)上的bash卖脚本文件 . 我从github下载了一个Deep-learning代码包,并将它们上传到我的google驱动器上,然后在Google Colab上安装goole驱动器代码包中包含'* . py'python代码和'fn.sh'脚本文件 . 通过执行脚本文件,可以执行python代码 .
我在Google Colab的ipython提示符下尝试了os.system('fn.sh')和subprocess.call('fn.sh'),但是它们不能像下面那样工作 .
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格式错误:'drive / DL / denet-master / examples / simple-cifar10 . SH”
1 回答
在Colab中,您可以使用
!
或%%shell
调用shell命令 .您的上述调用将是:
!drive/DL/denet-master/examples/simple-cifar10.sh
这是一个示例笔记本:
https://colab.research.google.com/drive/1N7p0B-7QWEQ9TIWRgYLueW03uJgJLmka