问题
Is there any convention or configuration setting for how to start IPython shell? For example, when I start IPython, I almost always start it with pylab --inline. One approach is to create an alias, such as alias ipython="ipython --pylab inline". However, I think it's impossible to start the shell with different options (other than inline option) once I decide to create and use the alias.
So is it feasible to always start the shell with pylab=inline option, but still to toggle it off whenever I don't need it (or more correctly, whenever I want to avoid it)?
(Don't suggest to create an alias with different names, such as ipy or ipyWithPylab, please.)
Thanks.
回答1:
ipython qtconsole --help-all says :
--IPKernelApp.matplotlib=<CaselessStrEnum>
Default: None
Choices: ['auto', 'gtk', 'inline', 'osx', 'qt', 'qt4', 'tk', 'wx']
--IPKernelApp.pylab=<CaselessStrEnum>
Default: None
Choices: ['auto', 'gtk', 'inline', 'osx', 'qt', 'qt4', 'tk', 'wx']
Pre-load matplotlib and numpy for interactive use, selecting a particular
matplotlib backend and loop integration.
so c.IPKernelApp.matplotlib='inline'in your *_config.py(probably in ~/.ipython/profile_default) will work. Please read how to configure IPyton, usually doc explain a lot of things on how to do stuff.
Be careful though, there is a difference between having inlines figures and having a %pylab kernel. It is not possible to un-pylab a kernel (like it is impossible in python to un-import a module). With 1.0 and above and recent matplotlib, you can toggle inline/not inline with the %matplotlib <backend> magic.
来源:https://stackoverflow.com/questions/19902984/always-start-ipython-with-pylab-being-equal-to-inline-but-toggle-it-off-at-some