Magic function `bash ` not found

廉价感情. 提交于 2019-12-08 06:44:34

问题


I have a bunch of simulations that I want to run on a high-performance cluster, on which I should make reservations to get computing time. Since the reservations are bounded by time, I am developing an automation script that I can scp into the cluster and run. This script will then download the relevant simulation files, run them, and upload the results.

Part of this automation script is in bash (cp, scp, etc) and the rest is in python. In order to develop this automation, I am using an IPython notebook.

So far, I've coded all the python automation stuff in my IPython notebook and am trying to write the bash part of it now.

However, it seems that the magic %%bash doesn't work in my IPython notebook. I get the following error when I have this code in my cell:


Cell

%%bash

echo hi

Error

  File "<ipython-input-22-62ec98e35224>", line 3
    echo hi
          ^
SyntaxError: invalid syntax

On a whim, I tried this:


Cell

%%bash

print "hi"

Error

hi
ERROR: Magic function `bash` not found.

So I tried this with %%system, %%! and %%shell. But none of those work; they all give me the same error.

Why is this happening? How can I fix this?

Metadata:

  • IPython 0.13.dev
  • Python 2.7.1
  • Mac OS X Lion

回答1:


This was caused by a version error. I upgraded my IPython version (0.13.1, now) and this works just fine.

So it would seem that this issue was using the dev version (which was the latest version when I installed IPython).




回答2:


You will also get similar errors when you try to use %%bash on a windows ipython. %%bash is not available there. Instead you get %%cmd. That is not the same though as cmd is not bash.



来源:https://stackoverflow.com/questions/13774602/magic-function-bash-not-found

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