How to run shell script file on ipython at Google Colab

不羁岁月 提交于 2019-12-06 09:23:35

问题


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.

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'


回答1:


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

Your invocation above would be:

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

Here's an example notebook:

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



来源:https://stackoverflow.com/questions/52343308/how-to-run-shell-script-file-on-ipython-at-google-colab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!