[IPython-User] Running profile startup files in an embedded IPython instance

Kevin Tran hekevintran@gmail....
Mon Apr 9 11:21:30 CDT 2012


I also notice that embedded shells cannot access store'd values.

When I try to store a value I get a SyntaxError:
In [3]: store a
  File "<ipython-input-3-7733c1c15039>", line 1
    store a
          ^
SyntaxError: invalid syntax

Is the store'd database not available to embedded shells for a similar reason? Is there a way to make %store work in an embedded shell?

> As discussed here <https://github.com/ipython/ipython/issues/1536
> >, startup
> scripts/code are one way of initializing the namespace, while embedding in
> a scope is another.  It's unusual to do both, so there isn't an
> official/convenient way to do this.  Once you have started the embedded
> session, you can run all your startup scripts yourself pretty easily:
> 
> import os, glob
> for f in glob.glob(os.path.join(get_ipython().profile_dir.startup_dir,
> '*.py')):
>     %run -i $f
> 
> -MinRK
> 
> On Sun, Apr 8, 2012 at 10:16, Kevin Tran <
> hekevintran@gmail.com
> > wrote:
> 
> >
>  I want to use an embedded IPython shell with a user_ns dictionary and a my
> 
> >
>  profile configuration (ipython_config.py and the startup files). The
> 
> >
>  purpose is to run a Django shell with models imported on startup.
> 
> >
>  django-extensions implements a command called shell_plus that does this:
> 
> >
> >
> >
> > https://github.com/django-extensions/django-extensions/blob/master/django_extensions/management/commands/shell_plus.py
> >
> >
>     from IPython import embed
> 
> >
>     embed(user_ns=imported_objects)
> 
> >
> >
>  The problem is that this does not load my startup files. embed() calls
> 
> >
>  load_default_config() which I figure loads ipython_config.py.
> 
> >
> >
>  How do I make the embedded IPython instance run my profile startup files?
> 
> >
> >
>  _______________________________________________
> 
> >
>  IPython-User mailing list
> 
> > IPython-User@scipy.org
> > http://mail.scipy.org/mailman/listinfo/ipython-user
> >


More information about the IPython-User mailing list