ipython 0.12 embed shell won't run startup scripts #1536

seenxu opened this Issue Mar 30, 2012 · 5 comments


None yet

3 participants

seenxu commented Mar 30, 2012

start normarl ipython session, the startup scripts run fine, but with embed shell, it won't works, script snippet looks like the following.

    import IPython

    from IPython.frontend.terminal.embed import InteractiveShellEmbed

    os.environ["IPYTHONDIR"] = "${buildout:directory}/conf/etc/ipython/"

    config = "${buildout:directory}/conf/etc/ipython/profile_default/ipython_config.py"
    cf = IPython.config.loader.PyFileConfigLoader(config)

    shell = InteractiveShellEmbed(config=cf.load_config())

someone on mailing list had also reports a similar issue, but there is no answer so far.



minrk commented Mar 30, 2012

running startup scripts is part of Application, not the shell itself. That is, the shell expects an initialized namespace, and the Application is what does this. When you are embedding IPython, then you are initializing the namespace with the calling scope, rather than with exec_lines/files. It doesn't make a great deal of sense to me to do both at the same time.

I guess my question is, do you really want embedded IPython, or just a regular IPython session that you started yourself?

seenxu commented Mar 30, 2012

thx for the detailed explanation, actually I have no idea about how all the different shells work, or choose the right shell to use, now it's clear that the embed shell has no such feature to load startup scripts.

fperez commented Apr 18, 2012

@seenxu, since you can pass to the shell a namespace, you can do

execfile('your_script.py', namespace)

and then pass that namespace to the shell. Does that address what you're trying to do?

seenxu commented Apr 19, 2012

@fperez thx for your tip, what I want is just to import some modules, I had worked around it with script like the following,


import xxx
import yyy

import IPython

if __name__ == '__main__':

after run shell.py, I can directly use xxx and yyy module.

fperez commented Apr 19, 2012

OK, that works too. It seems to me we can close this one; feel free to reopen (or leave a comment) if you disagree.

@fperez fperez closed this Apr 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment