ipython notebook config options ignored unless placed in regular config file

Rob Clewley <[email protected]> Sat, 18 Apr 2015 20:14:35 -0400
Newsgroups gmane.comp.python.ipython.user
Message-ID <CA+7tCyTp7EGD9e5XhW_mqWsr+8sxRjk7ZQATv6pNue2Q6wFjcA@mail.gmail.com>
Hi,

I'm using OS X 10.6.8 with ipython that I upgraded from v1 (from fink)
to 3.0.0 (using pip). Everything seems to work fine, except an issue
with configuration.

>From the documentation and my own testing, I am having trouble
understanding the expected behavior of config options in my
.ipython/profile_default/ipython_config.py versus the
ipython_notebook_config.py.

I want to auto-load a couple of extensions and modules for my
notebooks but not for my regular ipython sessions (partly because
those loads create warnings, but it just seems that I'm supposed to be
able to keep these configurations separate). It seemed to make sense
that config options that apply only to the notebook go in the notebook
config. But I can only get the notebook to honour my choices when I
put the options in ipython_config.py. It seems to ignore the notebook
config, and I am stuck with non-notebook ipython also loading these
modules. Am I doing something wrong?

The documentation does not explicitly address the distinctions, and
the inline comments in these files do not make reference to the
distinction between these two config files, only to inheritance of
TerminalIPythonApp from Application and InteractiveShellApp (but same
class names in both config files). What is the rule for notebook
config reading? Does ipython read from one first, then the other?
Currently, it seems to ignore the ipython_notebook_config.py
altogether, so why is it there?

Maybe it's related to this from 2013:
http://mail.scipy.org/pipermail/ipython-user/2013-February/012170.html
But the commit that fixed his problem is in the master repo now, so
maybe not...

The result of ipython notebook --debug is

[D 10:37:52.595 NotebookApp] Config changed:
[D 10:37:52.595 NotebookApp] {'NotebookApp': {'log_level': 10}}
[D 10:37:52.596 NotebookApp] IPYTHONDIR set to: /Users/robclewley/.ipython
[I 10:37:52.598 NotebookApp] Using existing profile dir:
u'/Users/robclewley/.ipython/profile_default'
[D 10:37:52.598 NotebookApp] Searching path
[u'/Users/robclewley/Work/literate_modeling/scenario-local-linear/notebook/project',
u'/Users/robclewley/.ipython/profile_default',
'/usr/local/etc/ipython', '/etc/ipython'] for config files
[D 10:37:52.598 NotebookApp] Attempting to load config file: ipython_config.py
[D 10:37:52.600 NotebookApp] Loaded config file:
/Users/robclewley/.ipython/profile_default/ipython_config.py
[D 10:37:52.601 NotebookApp] Config changed:
[D 10:37:52.601 NotebookApp] {'TerminalInteractiveShell': {'logstart':
True}, 'NotebookApp': {'log_level': 10}, 'TerminalIPythonApp':
{'matplotlib': 'osx'}}
[D 10:37:52.602 NotebookApp] Attempting to load config file:
ipython_notebook_config.py
[D 10:37:52.604 NotebookApp] Loaded config file:
/Users/robclewley/.ipython/profile_default/ipython_notebook_config.py
[D 10:37:52.605 NotebookApp] Config changed:
[D 10:37:52.605 NotebookApp] {'TerminalInteractiveShell': {'logstart':
True}, 'NotebookApp': {'log_level': 10}, 'InteractiveShellApp':
{'exec_lines': ['import notebook_importing'], 'gui': 'osx', 'pylab':
'osx', 'matplotlib': 'osx', 'extensions': ['yaml_magic',
'autoreload'], 'extra_extension': 'yaml_magic'}, 'TerminalIPythonApp':
{'extra_extension': 'yaml_magic', 'extensions': ['yaml_magic'],
'matplotlib': 'osx'}}
[D 10:37:52.611 NotebookApp] searching for local mathjax in
[u'/Users/robclewley/.ipython/nbextensions',
'/sw/share/jupyter/nbextensions',
'/usr/local/share/jupyter/nbextensions',
'/usr/share/jupyter/nbextensions']
[D 10:37:52.613 NotebookApp] searching for local mathjax in
[u'/Users/robclewley/.ipython/profile_default/static',
'/sw/lib/python2.7/site-packages/IPython/html/static']
[I 10:37:52.613 NotebookApp] Using MathJax from CDN:
https://cdn.mathjax.org/mathjax/latest/MathJax.js

For instance, invoking the magic command %%yaml (from my custom
extension) in the notebook results in a complaint that the command is
not recognized. If, instead, I set these extensions to be loaded in
ipython_config.py, then the notebook accepts %%yaml immediately. In
this case, the debug output is:

[D 10:46:50.330 NotebookApp] Config changed:
[D 10:46:50.330 NotebookApp] {'NotebookApp': {'log_level': 10}}
[D 10:46:50.331 NotebookApp] IPYTHONDIR set to: /Users/robclewley/.ipython
[I 10:46:50.332 NotebookApp] Using existing profile dir:
u'/Users/robclewley/.ipython/profile_default'
[D 10:46:50.332 NotebookApp] Searching path
[u'/Users/robclewley/Work/literate_modeling/scenario-local-linear/notebook/project',
u'/Users/robclewley/.ipython/profile_default',
'/usr/local/etc/ipython', '/etc/ipython'] for config files
[D 10:46:50.332 NotebookApp] Attempting to load config file: ipython_config.py
[D 10:46:50.335 NotebookApp] Loaded config file:
/Users/robclewley/.ipython/profile_default/ipython_config.py
[D 10:46:50.336 NotebookApp] Config changed:
[D 10:46:50.337 NotebookApp] {'TerminalInteractiveShell': {'logstart':
True}, 'NotebookApp': {'log_level': 10}, 'InteractiveShellApp':
{'extensions': ['yaml_magic', 'autoreload']}, 'TerminalIPythonApp':
{'matplotlib': 'osx'}}
[D 10:46:50.337 NotebookApp] Attempting to load config file:
ipython_notebook_config.py
[D 10:46:50.338 NotebookApp] Loaded config file:
/Users/robclewley/.ipython/profile_default/ipython_notebook_config.py
[D 10:46:50.339 NotebookApp] Config changed:
[D 10:46:50.340 NotebookApp] {'TerminalInteractiveShell': {'logstart':
True}, 'NotebookApp': {'log_level': 10}, 'InteractiveShellApp':
{'extra_extension': 'yaml_magic', 'extensions': ['yaml_magic',
'autoreload'], 'exec_lines': ['import notebook_importing'], 'gui':
'osx', 'pylab': 'osx', 'matplotlib': 'osx'}, 'TerminalIPythonApp':
{'extra_extension': 'yaml_magic', 'extensions': ['yaml_magic'],
'matplotlib': 'osx'}}
[D 10:46:50.345 NotebookApp] searching for local mathjax in
[u'/Users/robclewley/.ipython/nbextensions',
'/sw/share/jupyter/nbextensions',
'/usr/local/share/jupyter/nbextensions',
'/usr/share/jupyter/nbextensions']
[D 10:46:50.345 NotebookApp] searching for local mathjax in
[u'/Users/robclewley/.ipython/profile_default/static',
'/sw/lib/python2.7/site-packages/IPython/html/static']

Thanks.