Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot load extensions configurator if using custom jupyter notebook config file #23

Closed
pybokeh opened this issue Nov 10, 2016 · 5 comments

Comments

@pybokeh
Copy link

pybokeh commented Nov 10, 2016

Hello, I created a custom jupyter notebook config file and so I launch jupyter notebook with the --config= parameter:
jupyter notebook --config=/path/jupyter_notebook_config_custom.py

In the terminal, I get no errors, but I notice I don't get the message:
Loaded extension jupyter_nbextensions_configurator

and so if I go to http://localhost:8888/nbextensions/ I get the http 404 error. I can still manually install extensions with the enable sub-command:
jupyter nbextension enable <extension>

If I launch jupyter notebook with default config file ("jupyter_notebook_config.py"), I get the message:
Loaded extension jupyter_nbextensions_configurator

and therefore, nbextensions configurator is loaded ok and everything works as expected.

What I did, I just make a copy of the default config file (jupyter_notebook_config.py) and then just rename it to jupyter_notebook_config_custom.py, modify the port #, then do:
jupyter notebook --config=/path/jupyter_notebook_config_custom.py

and the nbextensions configurator does not get loaded. This is very unexpected. So it appears if I am not using a config file exactly called "jupyter_notebook_config.py", the nbextensions configurator doesn't get loaded.

@pybokeh
Copy link
Author

pybokeh commented Nov 10, 2016

Sorry forgot to add that I installed using pip, not conda and using python 3.5.2 and notebook version 4.2.3.

I saw issue #11 but don't think it is related. I am not using jupyterhub.

@jcb91
Copy link
Member

jcb91 commented Nov 11, 2016

Correct, this is unrelated to #11. It is to do with which config files things are in, and specifically where the jupyter_nbextensions_configurator serverextension is enabled.

In brief, to get this working as you hope it to, your simplest option (assuming you want to keep a python config file), would be to add the following line to your jupyter_notebook_config_custom.py file:

c.NotebookApp.set_default('nbserver_extensions', {})['jupyter_nbextensions_configurator'] = True

In more detail, the reasons this is happening:

If you used the provided jupyter subcommand to enable the configurator

jupyter nbextensions_configurator enable

then it works by editing a jupyter_notebook_config.json config file in the relevant jupyter config directory (which is dependent on --user, --system or --sys-prefix flags). The same is true if you got the configurator from ipython-contrib/jupyter_contrib_nbextensions, which does the same thing.

This is normally compatible with a jupyter_notebook_config.py file, as both get loaded by the server, as part of the normal config loading process of a jupyter_core.application.JupyterApp instance (which the notebook app is). However, using the --config cli option is causing problems as follows:

  • from jupyter_core/application.py#L46, we can see that the --config= command line option will alter the application's config_file trait.
  • from jupyter_core/application.py#L190-L191 we can see that setting the config file causes the application to alter what config filename it is looking for, so that instead of looking for jupyter_notebook_config.json, your app will end up looking for jupyter_notebook_config_custom.json, which of course doesn't exist. Since the config file where the serverextension is specified isn't loaded, the servereextension doesn't get loaded.

@pybokeh
Copy link
Author

pybokeh commented Nov 11, 2016

@jcb91 Thanks for the explanation! I was wondering, could I also have copied over the jupyter_notebook_config.json as jupyter_notebook_config_custom.json?

@jcb91
Copy link
Member

jcb91 commented Nov 11, 2016

No problem :)

could I also have copied over the jupyter_notebook_config.json as jupyter_notebook_config_custom.json

Yes, as far as I can tell, that should also work just fine

@jcb91 jcb91 closed this as completed Mar 18, 2017
@doufuxixi123
Copy link

i use conda to install nbextensions. like following, and get problem.
conda install -c conda-forge jupyter_nbextensions_configurator

problem describe:
there are not items to check in nbextensions configurable panel. and tell these words:
add an edit-menu item to open the nbextensions configurator page

solving:
1/ uninstall nbextensions:
conda uninstall jupyter_nbextensions_configurator
2/ install nbextensions via pip:
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
jupyter nbextension enable codefolding/main

may be the problem due to own company jupyter setting. when i download jupyter_contrib_nbextensions via pip. the package download from own company repository, not from website.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants