[IPython-user] non-interactive ipython for script

Reckoner reckoner@gmail....
Mon Dec 10 14:37:13 CST 2007


I managed to resolve my own dilemma. For posterity, I'm going to record the
solution to my dilemma here:

If you want to run ipython commands within a python script you need to do
something like

from IPython.Shell import IPShellEmbed
ipshell = IPShellEmbed()
ip=ipshell.IP

and then if you have _ipmagic commands you want to run, you can do

ip.ipmagic("px import os")

for example.

This is a big help when running parallel ipython1 commands.

On Dec 5, 2007 10:00 AM, <ipython-user-request@scipy.org> wrote:

> Send IPython-user mailing list submissions to
>        ipython-user@scipy.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://lists.ipython.scipy.org/mailman/listinfo/ipython-user
> or, via email, send a message with subject or body 'help' to
>        ipython-user-request@scipy.org
>
> You can reach the person managing the list at
>        ipython-user-owner@scipy.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of IPython-user digest..."
>
>
> Today's Topics:
>
>   1. non-interactive ipython for script (Reckoner)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 4 Dec 2007 14:40:17 -0500
> From: Reckoner <reckoner@gmail.com>
> Subject: [IPython-user] non-interactive ipython for script
> To: ipython-user@scipy.org
> Message-ID:
>        <a1b53c580712041140r19aa9e6fg2018d9e53f563da9@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> I  need to be able to run certain ipython magic commands using the plain
> vanilla python interpreter.
>
> In other words, I have an ipython script that I can certainly invoke using
> ipython on the command line, but I need to  run the script using python on
> the command line.
>
> I know it has  something to do with importing IPython, but I can't do the
> IPython.Shell.start().mainloop() part since I need non-interactive
> running.
>
> I hope that made some sense.
>
> Any help appreciated.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://lists.ipython.scipy.org/pipermail/ipython-user/attachments/20071204/e7802df1/attachment-0001.html
>
> ------------------------------
>
> _______________________________________________
> IPython-user mailing list
> IPython-user@scipy.org
> http://lists.ipython.scipy.org/mailman/listinfo/ipython-user
>
>
> End of IPython-user Digest, Vol 50, Issue 2
> *******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ipython.scipy.org/pipermail/ipython-user/attachments/20071210/461f68a3/attachment.html 


More information about the IPython-user mailing list