[IPython-User] Startup files don't get loaded when using embedded IPython (InteractiveShellEmbed)

MinRK benjaminrk@gmail....
Thu Jan 31 10:42:14 CST 2013


On Thu, Jan 31, 2013 at 6:01 AM, Ingo Fischer <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
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20130131/a313e127/attachment-0001.html 


More information about the IPython-User mailing list