Take the 2-minute tour ×

I am often asked to debug Python scripts written by others. I would like to send these scripts to IPython so it will drop into an IPython shell at the point the script fails.

Unfortunately, I cannot find a way to send (required) command-line options required by the scripts.

IPython assumes everything in is for IPython when I pass the script and its options as:

ipython <script_name> <script_options>

Is there a solution or workaround?


share|improve this question
add comment

3 Answers

up vote 15 down vote accepted
ipython -i -c "%run test.py 1 2 3 4"

EDIT: added -i

share|improve this answer
Very nice! Unfortunately, when it exceptions out, it drops me back onto the OS command line, not onto the IPython prompt. Suggestions? –  JS. Nov 9 '10 at 20:29
Well you could just start ipython and then do %run test.py 1 2 3 4 –  dr jimbob Nov 9 '10 at 20:30
Actually adding the -i makes it stay in the shell. –  dr jimbob Nov 9 '10 at 20:34
Perfect! Thank you! –  JS. Nov 9 '10 at 20:36
@jimbob If you don't mind me asking, where'd you find the '-i' option? I'm having no luck finding it in 'ipython -help' nor 'ipython.scipy.org/doc/stable/html/interactive/…; –  JS. Nov 9 '10 at 20:40
show 2 more comments
ipython -- sometest.py 1 2 3 4
share|improve this answer
It works, but I could not find this in the docs, can you point me to where this is documented? –  Daniel Sokolowski Nov 29 '12 at 19:17
Also to remain within the interactive shell use ipython -i -- sometest.py 1 2 3 4 syntax. –  Daniel Sokolowski Nov 29 '12 at 19:46
add comment

I know there's an already accepted solution, but in the most recent version of ipython this won't work. Here's a cut and paste of the command I use to run tornado tests with --autoreload

ipython --c="%run test.py --autoreload"

This is using ipython .11.

share|improve this answer
add comment

Your Answer


