问题
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