Question

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
Was it helpful?

Solution

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).

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top