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

MinRK benjaminrk@gmail....
Sun Apr 8 14:07:52 CDT 2012

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,
    %run -i $f


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20120408/3a135788/attachment.html 

More information about the IPython-User mailing list