[IPython-User] Startup files don't get loaded when using embedded IPython (InteractiveShellEmbed)
Ingo Fischer
mail@ingofischer...
Fri Feb 1 03:28:28 CST 2013
So as startup files don't work I just provide the content of my startup
file to the InteractiveShellEmbed via user_ns.
What I'm trying to do:
I'm currently tweaking the django-extensions (especially the
"shell_plus" command) to get a highly enhanced shell for my Django
project. For example I'm showing the current Django logging settings
inside the IPython prompt.
As the django-extensions already provide a user_ns to
InteractiveShellEmbed (its pre-loading the db models), I just had to add
my own modules from my startup script inside the method which retrieves
the user_ns-packages, and so I got it running.
Thanks for the help!
Cheers,
Ingo
Am 01/31/2013 05:42 PM, schrieb MinRK:
>
>
> On Thu, Jan 31, 2013 at 6:01 AM, Ingo Fischer <mail@ingofischer.de
> <mailto:mail@ingofischer.de>> wrote:
>
> Hello *,
>
> How can I load startup files when using embedded IPython
> (InteractiveShellEmbed)?
> I tried ipython 0.13.1 and 0.14 dev.
>
> This is a little script to test if startup files are loaded:
>
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
> import os
> import IPython
> from IPython.frontend.terminal.embed import InteractiveShellEmbed
>
> homedir = os.environ['HOME']
> cfgfile =
> "%s/.config/ipython/profile_default/ipython_config.py" % homedir
> cfg =
> IPython.config.loader.PyFileConfigLoader(cfgfile).load_config()
> ipshell = InteractiveShellEmbed(config=cfg)
> ipshell()
>
> Then I configured the startupfiles in my ipython_config:
>
> c.InteractiveShellApp.exec_files = ["/tmp/test.py"]
>
> and I also tried
>
> c.InteractiveShellEmbed.exec_files = ["/tmp/tmpfile.py"]
>
>
> Inside temp.py I have a little print statement.
>
> When running IPython from the shell, the startup script is
> executed and the message is printed.
> When running IPython in embedded mode, the message is *not* printed.
>
> Seems that these configuration values are not picked up when
> running the embedded shell.
> Does the embedded shell support startup scripts at all?
>
>
> No, it does not. There are two ways to initialize the namespace for
> IPython:
>
> 1. use startup files / code to perform executions, imports, define
> names, etc. (regular IPython shell startup)
> 2. embed IPython in a particular scope of another Python program.
> (InteractiveShellEmbed).
>
> Do you actually intend to embed IPython into a particular namespace?
> Or do you merely want to start IPython programmatically?
> Some folks use embed when that's not really what they want.
>
> -MinRK
>
>
> Cheers,
> Ingo
>
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org <mailto:IPython-User@scipy.org>
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
>
>
>
> _______________________________________________
> 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/20130201/ff90a59e/attachment.html
More information about the IPython-User
mailing list