ipython-contrib / jupyter_contrib_nbextensions

A collection of various notebook extensions for Jupyter
http://jupyter-contrib-nbextensions.readthedocs.io/en/latest
Other
5.2k stars 804 forks source link

Cannot configure while the Jupyter notebook server #1090

Open nick-youngblut opened 6 years ago

nick-youngblut commented 6 years ago

I'm trying to install the jupyter_contrib_nbextensions with conda. I get the following error when trying to install (here, just showing a subset of the error):

Traceback (most recent call last):
  File "/ebio/abt3_projects/small_projects/nyoungblut/dev/data_analysis_workshops/anaconda3/bin/jupyter-contrib-nbextension", line 11, in <module>
    load_entry_point('jupyter-contrib-nbextensions==0.3.1', 'console_scripts', 'jupyter-contrib-nbextension')()
  File "/ebio/abt3_projects/small_projects/nyoungblut/dev/data_analysis_workshops/anaconda3/lib/python3.6/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/ebio/abt3_projects/small_projects/nyoungblut/dev/data_analysis_workshops/anaconda3/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/ebio/abt3_projects/small_projects/nyoungblut/dev/data_analysis_workshops/anaconda3/lib/python3.6/site-packages/jupyter_contrib_nbextensions/application.py", line 226, in start
    super(ContribNbextensionsApp, self).start()
  File "/ebio/abt3_projects/small_projects/nyoungblut/dev/data_analysis_workshops/anaconda3/lib/python3.6/site-packages/jupyter_core/application.py", line 256, in start
    self.subapp.start()
  File "/ebio/abt3_projects/small_projects/nyoungblut/dev/data_analysis_workshops/anaconda3/lib/python3.6/site-packages/jupyter_contrib_nbextensions/application.py", line 173, in start
    toggle_install_files(self._toggle_value, **kwargs_files)
  File "/ebio/abt3_projects/small_projects/nyoungblut/dev/data_analysis_workshops/anaconda3/lib/python3.6/site-packages/jupyter_contrib_nbextensions/install.py", line 60, in toggle_install_files
    'Cannot configure while the Jupyter notebook server is running')
jupyter_contrib_nbextensions.install.NotebookRunningError: Cannot configure while the Jupyter notebook server is running

The conda install prompt shows the following:

The following NEW packages will be INSTALLED:

    jupyter_contrib_core:              0.3.3-py36_0  conda-forge
    jupyter_nbextensions_configurator: 0.2.7-py36_0  conda-forge

The following packages will be SUPERSEDED by a higher-priority channel:

    conda:                             4.3.25-py36_0             --> 4.3.23-py36_0 conda-forge
    conda-env:                         2.6.0-0                   --> 2.6.0-0       conda-forge

I have other jupyter notebooks running but they are in different conda environments in different anaconda installs at various locations on the server. Why is jupyter_contrib_nbextensions assessing jupyter notebooks in other isolated conda environments? Do I have to shut down all notebooks in order to install jupyter_contrib_nbextensions?

nick-youngblut commented 6 years ago

My "Nbextensions configuration" looks like the following:

screen shot 2017-09-13 at 10 22 31

For all of the extensions, I get the following: ...but doesn't provide a yaml file to tell us how to configure it

However, the *.yaml files seem to be present:

data_analysis_workshops/anaconda3/pkgs/jupyter_contrib_nbextensions-0.3.1-py36_0/lib/python3.6/site-packages/jupyter_contrib_nbextensions/nbextensions/python-markdown/python-markdown.yaml
data_analysis_workshops/anaconda3/pkgs/jupyter_contrib_nbextensions-0.3.1-py36_0/lib/python3.6/site-packages/jupyter_contrib_nbextensions/nbextensions/codefolding/codefolding.yaml
data_analysis_workshops/anaconda3/pkgs/jupyter_contrib_nbextensions-0.3.1-py36_0/lib/python3.6/site-packages/jupyter_contrib_nbextensions/nbextensions/codefolding/codefolding_editor.yaml
data_analysis_workshops/anaconda3/pkgs/jupyter_contrib_nbextensions-0.3.1-py36_0/lib/python3.6/site-packages/jupyter_contrib_nbextensions/nbextensions/runtools/runtools.yaml
data_analysis_workshops/anaconda3/pkgs/jupyter_contrib_nbextensions-0.3.1-py36_0/lib/python3.6/site-packages/jupyter_contrib_nbextensions/nbextensions/scroll_down/config.yaml
... [a total of 58 *.yaml files in this directory]
jcb91 commented 6 years ago

I have other jupyter notebooks running but they are in different conda environments in different anaconda installs at various locations on the server. Why is jupyter_contrib_nbextensions assessing jupyter notebooks in other isolated conda environments? Do I have to shut down all notebooks in order to install jupyter_contrib_nbextensions?

So the install command uses the notebook.notebookapp.list_running_servers function. Although this allows you to specify a runtime directory in which to check for servers, the default jupyter runtime directory is set system-wide, so there isn't really a reliable way to distinguish between environments. Personally, I don't think installing while notebook servers are running is a problem at all, excepting the rare case where a config file gets edited while the notebook server is reading it, which I think is probably rare enough to consider acceptable. Certainly other extensions like nb_conda_kernels and nb_anacondacloud don't bother with this check.

Anyway, since it's part of the post-link step in the conda install, the python package gets installed ok (as you have observed, all the yaml files are present in the python package's nbextensions directory), and you can manually run the second step of the install ignoring running servers, using

jupyter contrib nbextensions install --sys-prefix --skip-running-check

from the appropriate conda environment.

To clarify, the reason all the yaml files are present, but not found by the notebook server, is that the notebook server looks for nbextensions in the jupyter path, but the yaml files you've found are part of the python package (for distribution) and haven't been correctly copied into any of the jupyter data directories.

I hope some of that makes sense - let me know if not.

Any thoughts on removing/making non-default the running check @nick-youngblut, @jfbercher @juhasch?

nick-youngblut commented 6 years ago

Thanks for the clarification! I tried jupyter contrib nbextensions install --sys-prefix --skip-running-check and just got the following:

community-contributed spice for Jupyter Interactive Computing

Options
-------

Arguments that take values are actually convenience aliases to full
Configurables, whose aliases are listed on the help line. For more information
on full configurables, see '--help-all'.

--debug
    set log level to logging.DEBUG (maximize logging output)
--generate-config
    generate default config file
-y
    Answer yes to any questions instead of prompting.
--log-level=<Enum> (Application.log_level)
    Default: 30
    Choices: (0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL')
    Set the log level by value or name.
--config=<Unicode> (JupyterApp.config_file)
    Default: ''
    Full path of a config file.

To see all available configurables, use `--help-all`

[JupyterContribApp] CRITICAL | Bad config encountered during initialization:
[JupyterContribApp] CRITICAL | Unrecognized flag: '--sys-prefix'

I'm guessing that I should be using different options rather than: --sys-prefix and --skip-running-check.

jcb91 commented 6 years ago

blegh, try

jupyter contrib nbextension

without the s? Or possibly even

jupyter-contrib-nbextension
nick-youngblut commented 6 years ago

jupyter-contrib -h and jupyter-contrib nbextension -h produce the same output on options:

community-contributed spice for Jupyter Interactive Computing

Options
-------

Arguments that take values are actually convenience aliases to full
Configurables, whose aliases are listed on the help line. For more information
on full configurables, see '--help-all'.

--debug
    set log level to logging.DEBUG (maximize logging output)
--generate-config
    generate default config file
-y
    Answer yes to any questions instead of prompting.
--log-level=<Enum> (Application.log_level)
    Default: 30
    Choices: (0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL')
    Set the log level by value or name.
--config=<Unicode> (JupyterApp.config_file)
    Default: ''
    Full path of a config file.

To see all available configurables, use `--help-all'`

I'm not see where --sys-prefix or --skip-running come in to play.

jcb91 commented 6 years ago

Yeah, the help message is for the jupyter-contrib script, which should find the nbextension subcommand (which accepts the flags) from pkg_resources. Perhaps the subcommand script hasn't been installed correctly 🤔

jcb91 commented 6 years ago

You could alternatively do this in python, I guess:

from jupyter_contrib_nbextensions.install import toggle_install

toggle_install(True, sys_prefix=True, skip_running_check=True)
juhasch commented 6 years ago

jupyter-contrib-nbextension install --help-all or jupyter contrib nbextension install --help-all will give you the options. Alternatively just --help will do.

nick-youngblut commented 6 years ago

Yeah, conda install -c conda-forge jupyter_contrib_nbextensions failed due to the error: Cannot configure while the Jupyter notebook server is running, which is probably why the nbextensions subcommand is not found.

nick-youngblut commented 6 years ago

jupyter-contrib-nbextension isn't installed due to the failed install (the error: Cannot configure while the Jupyter notebook server is running).

jcb91 commented 6 years ago

Weird, that script should get copied as part of the python package install (which seems to have happened ok), before the post-link script (which is what fails). Oh well, it's not super important, as it doesn't do much beyond install/uninstall. Given all these complications, you may be better off following the pip package installation instructions from scratch, using the --sys-prefix and --skip-running-check flags...

nick-youngblut commented 6 years ago

OK, the following worked:

pip install jupyter_contrib_nbextensions
jupyter contrib nbextensions install --sys-prefix --skip-running-check

Thanks for your help!

lportelli4 commented 6 years ago

I had this same issue even though I had closed all my my notebooks and restarted my computer. The final comment worked for me!

IreneCrisologo commented 6 years ago

I had this issue too and like @lportelli4 I closed all my notebooks and restarted the pc. The final comment (by @nick-youngblut ) solved it!

jcb91 commented 6 years ago

Hmm, it seems like the notebook code for detecting running servers is throwing up false positives then 🤔😞

juhasch commented 6 years ago

This is being discussed in https://github.com/jupyter/notebook/issues/2829

I guess we should add the --skip-running-check flag to the troubleshooting documentation.

juhasch commented 6 years ago

See PR #1100

helixg commented 6 years ago

I restarted my macbook and the last comment contributed by@nick-youngblut worked. My problem was I have both py2 and py3 environment, and my jupyter notebook is running on py3 while i try to install the nbextension on py2 environment. That's why i failed.

xshi0001 commented 6 years ago

I have problem on the second command jupyter_contrib_nbextensions when use pip : pip install jupyter_contrib_nbextensions image and I try to use conda: the same result : image image

and I use jupyter notebook list: image However I restart my pc ,it's the same errors

juhasch commented 6 years ago

So it looks like you have a stale nbserver list. This seems to happen sometimes with the notebook.

To clean this up, try executing jupyter --path:

(py36) imac:~ juhasch$ jupyter --path
config:
    /Users/juhasch/.jupyter
    /Users/juhasch/anaconda3/envs/py36/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /Users/juhasch/Library/Jupyter
    /Users/juhasch/anaconda3/envs/py36/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /Users/juhasch/Library/Jupyter/runtime

Then you will find the stale file in the runtime directory:

(py36) imac:~ juhasch$ ls -al /Users/juhasch/Library/Jupyter/runtime/nbser*
-rw-r--r--  1 juhasch  staff  264 14 Dez 20:30 /Users/juhasch/Library/Jupyter/runtime/nbserver-19710.json

If you remove it, jupyter notebook list should not report any running servers.

xshi0001 commented 6 years ago

That's meaning that I need to rmdir the runtime file? image image

juhasch commented 6 years ago

You need to remove the nbserver*.json file. The kernel*.json files can be removed too, I guess. I would not remove the notebook_cookie_secret file, otherwise I believe your existing notebooks will become untrusted (if you care about that).

xshi0001 commented 6 years ago

Thank you for your kind help, solve the problem of Cannot configure while the Jupyter notebook server is running, but a new problem has occur as the same partner nick-youngbl image and I try this way to install a new nbextension by this way: image such as I want to use the function of table of contents (2) image but the problem is that: image

xshi0001 commented 6 years ago

what a big trouble for me to solve it!!!, for pc:windows, jupyter contrib nbextension install --usermay just do the first things ,and do not do the second. (I guess) . so I need to copy all the extension files into C:\ProgramData\jupyter\nbextensions (the file nbextensions do not include anything ,though I have use the command jupyter contrib nbextension install --user in cmd) after I copy all the css and others into it.my notebook has changed! image

quant-dc commented 6 years ago

I had this issue too, for me it appeared to be caused by installing jupyter_nbextensions_configurator in isolation prior to jupyter_contrib_nbextensions.

My solution: conda remove jupyter_nbextensions_configurator

conda install -c conda_forge jupyter_contrib_nbextensions

(I installed the configurator first as part of BeakerX)

gokeplerride commented 6 years ago

@quant-dc when I tried your solution I got the following message...

PackagesNotFoundError: The following packages are missing from the target environment:
  - jupyter_nbextensions_configurator

I still don't have the extensions installed and still keep on getting this error message

jupyter_contrib_nbextensions.install.NotebookRunningError: Cannot configure while the Jupyter notebook server is running

when I run: conda install -c conda-forge jupyter_contrib_nbextensions

wardwissner commented 3 years ago

this may be very unscientific but I uninstalled nb_extensions configurator jupyter contrib nbextension uninstall --system

I reinstalled the package and it works

li11112223 commented 10 months ago

OK, the following worked:

pip install jupyter_contrib_nbextensions
jupyter contrib nbextensions install --sys-prefix --skip-running-check

it works Thanks for your help,bro