ipython-contrib / jupyter_contrib_nbextensions

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

Lots of problems installing extensions #282

Closed rabernat closed 9 years ago

rabernat commented 9 years ago

Also posted this at jupyter/notebook#389 since I wasn't sure where it belongs...

Apologies for this somewhat long issue. It describes my progress (and ultimate failure) to install jupyter extensions.

I just upgraded from ipython to jupyter and am trying to get my environment working properly. I upgraded using conda (conda install jupyter) and have jupyer 1.0.0 installed. I am trying to get extensions working, following these instructions: https://github.com/ipython-contrib/IPython-notebook-extensions/wiki/Home_Jupyter

First I was stuck on installing extensions: https://github.com/ipython-contrib/IPython-notebook-extensions/wiki/Home_Jupyter#1-installing-an-extension

When I first tried

 jupyter nbextension install usability/codefolding/main --user

I got a long stack trace ending with

IOError: [Errno 2] No such file or directory: u'usability/codefolding/main

It seemed like it was looking for an extension in my local file path, so I surmised I was supposed to clone the IPython-notebook-extensions repo and install the extensions from the base directory.

git clone git@github.com:ipython-contrib/IPython-notebook-extensions.git
cd IPython-notebook-extensions
jupyter nbextension install usability/codefolding/main --user

Still got the IOError. However, examining the repo files, I was able to finally get something to work

jupyter nbextension install usability/codefolding/main.js --user

This command completed without an error, so I assumed it was working. In fact, it put the file main.js into the path /Users/rpa/Library/Jupyter/nbextensions, which I presume is not the desired behavior.

After futher trial and error, I ended up with

$ jupyter nbextension install usability/codefolding --user

which gave me

copying /Users/rpa/RND/open_source/IPython-notebook-extensions/usability/codefolding/codefolding.py -> /Users/rpa/Library/Jupyter/nbextensions/codefolding/codefolding.py
copying /Users/rpa/RND/open_source/IPython-notebook-extensions/usability/codefolding/codefolding.yaml -> /Users/rpa/Library/Jupyter/nbextensions/codefolding/codefolding.yaml
copying /Users/rpa/RND/open_source/IPython-notebook-extensions/usability/codefolding/firstline-fold.js -> /Users/rpa/Library/Jupyter/nbextensions/codefolding/firstline-fold.js
copying /Users/rpa/RND/open_source/IPython-notebook-extensions/usability/codefolding/foldgutter.css -> /Users/rpa/Library/Jupyter/nbextensions/codefolding/foldgutter.css
copying /Users/rpa/RND/open_source/IPython-notebook-extensions/usability/codefolding/icon.png -> /Users/rpa/Library/Jupyter/nbextensions/codefolding/icon.png
copying /Users/rpa/RND/open_source/IPython-notebook-extensions/usability/codefolding/magic-fold.js -> /Users/rpa/Library/Jupyter/nbextensions/codefolding/magic-fold.js
copying /Users/rpa/RND/open_source/IPython-notebook-extensions/usability/codefolding/main.js -> /Users/rpa/Library/Jupyter/nbextensions/codefolding/main.js

Looked good. I now have all the extension files in /Users/rpa/Library/Jupyter/nbextensions/codefolding. So I did

jupyter nbextension enable usability/codefolding/main.js

As far as I can tell, all this does is put the following into /Users/rpa/.jupyter/nbconfig

{
  "load_extensions": {
    "usability/codefolding": true
  }
}

Now I start jupyter in my home directory with jupyter notebook. After creating a new python 2 notebook, I see the followin in the log

[I 12:54:30.137 NotebookApp] Kernel started: 35af37d8-82ec-4899-9b08-633f69adc7e8
[W 12:54:30.185 NotebookApp] 404 GET /nbextensions/usability/codefolding.js?v=20150903125424 (::1) 14.70ms referer=http://localhost:8888/notebooks/Untitled.ipynb?kernel_name=python2

which makes me think that the extension is not being found. Sure enough, the extension doesn't work. The following cell

import notebook
print(notebook.nbextensions.check_nbextension('usability/codefolding', user=True))
print(notebook.nbextensions.check_nbextension('usability/codefolding/main.js', user=True))

gives me False False.

I am using the most standard platform possible (anaconda on mac) and have tried to follow the instructions carefully, but I really don't see how to move forward. So there seems to be a bug in either the code or the documentation.

Any advice appreciated.

p.s. The output of my config / path info is

from __future__ import print_function
from jupyter_core.paths import jupyter_config_dir, jupyter_config_path
print(jupyter_config_dir())
print(jupyter_config_path())
/Users/rpa/.jupyter
['/Users/rpa/.jupyter', '/Users/rpa/anaconda/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter']
from __future__ import print_function
from jupyter_core.paths import jupyter_data_dir, jupyter_path
print(jupyter_data_dir())
print(jupyter_path())
/Users/rpa/Library/Jupyter
['/Users/rpa/Library/Jupyter', '/Users/rpa/anaconda/share/jupyter', '/usr/local/share/jupyter', '/usr/share/jupyter']
quartox commented 9 years ago

I am having very similar problems with the javascript not loading in my notebooks, but I was able to get the install checks to work. From the repository usability directory (for me: path to/IPython-notebook-extensions/usability/) use command line python to execute the following:

import notebook
notebook.install_nbextension('usability/python-markdown',user=True)
E=notebook.nbextensions.EnableNBExtensionApp()
E.enable_nbextension('python-markdown')

For me this passes the check: notebook.nbextensions.check_nbextension('python-markdown', user=True)

I hope this helps you, but if anyone else has further advice to why I might not be getting the extensions to load that would be appreciated. I am seeing the same 404 error in my javascript console.

juhasch commented 9 years ago

Installing notebook extensions can be really confusing. I struggled a lot, too. @rabernat : I think in your case the reason is that the extensions gets copied into codefolding/... instead of usability/codefolding/... So if you try print(notebook.nbextensions.check_nbextension('codefolding', user=True)) it most likely will work.

Hopefully I will get to making a conda recipe for notebook extensions in the next days, so it will be much easier installing extensions, as well as activating/deactivating them.

rabernat commented 9 years ago

@juhasch -- thanks for the tip! Yes, in fact, notebook.nbextensions.check_nbextension('codefolding', user=True) does return True.

However, I still can't actually get the extension to work. I am still getting the 404 errors in my log. I tried changing my ~/.jupyter/nbconfig/notebook.json file to read

{
  "load_extensions": {
    "codefolding": true
  }
}

to match the grammar from your check_extension suggestion, but that doesn't work either. The errors are like

[W 13:38:27.146 NotebookApp] 404 GET /nbextensions/codefolding.js?v=20150904133822 (::1) 16.28ms referer=http://localhost:8888/notebooks/lectures/test_extensions.ipynb

and the extension is not loading.

Any idea what I have to do to make it work?

juhasch commented 9 years ago

Try "codefolding/main": true, instead of "codefolding": true in the json file.

rabernat commented 9 years ago

Yes! It works! Thanks so much.

It seems like the wiki is inaccurate / incomplete, no? Is it out of date?

juhasch commented 9 years ago

IPython 4.x changed a lot of things. Please update the Wiki if you find it inaccurate. We will change from the Wiki to having the documentation directly in the repository. With many changes in each IPython/Jupyter version it is hard to keep the Wiki correct.

dartdog commented 9 years ago

I am similarly lost... don't see a recipe for simple install of JS extensions that works, start to finish I did an upgrade from Ipython to Jupyter in my base Python install, most everything works except this, I just went through trying: tom@tom-sam:~$ sudo jupyter nbextension install usability/codefolding/main /usr/local/lib/python2.7/dist-packages/IPython/utils/path.py:258: UserWarning: get_ipython_dir has moved to the IPython.paths module warn("get_ipython_dir has moved to the IPython.paths module") copying usability/codefolding/main -> /usr/local/share/jupyter/nbextensions/main Traceback (most recent call last): File "/usr/local/bin/jupyter-nbextension", line 11, in sys.exit(main()) File "/usr/local/lib/python2.7/dist-packages/jupyter_core/application.py", line 267, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 592, in launch_instance app.start() File "/usr/local/lib/python2.7/dist-packages/notebook/nbextensions.py", line 401, in start super(NBExtensionApp, self).start() File "/usr/local/lib/python2.7/dist-packages/jupyter_core/application.py", line 256, in start self.subapp.start() File "/usr/local/lib/python2.7/dist-packages/notebook/nbextensions.py", line 317, in start self.install_extensions() File "/usr/local/lib/python2.7/dist-packages/notebook/nbextensions.py", line 305, in install_extensions nbextensions_dir=self.nbextensions_dir, File "/usr/local/lib/python2.7/dist-packages/notebook/nbextensions.py", line 216, in install_nbextension _maybe_copy(src, full_dest, verbose) File "/usr/local/lib/python2.7/dist-packages/notebook/nbextensions.py", line 53, in _maybe_copy shutil.copy2(src, dest) File "/usr/lib/python2.7/shutil.py", line 130, in copy2 copyfile(src, dst) File "/usr/lib/python2.7/shutil.py", line 82, in copyfile with open(src, 'rb') as fsrc: IOError: [Errno 2] No such file or directory: u'usability/codefolding/main' tom@tom-sam:~$

I look forward to the better docs! If I need to clone the repo let me know,, also it sort of seems that This form may be depreciated? or will it work once installation is sorted out? %%javascript IPython.load_extensions('IPython-notebook-extensions-master/usability/python-markdown/main');

jcb91 commented 9 years ago

@dartdog looks to me from https://github.com/jupyter/notebook/issues/389 like this is ready to close too?

dartdog commented 9 years ago

absolutely closed as far as I'm concerned, I still can't get some JS extensions working but that is other topic (now that I have the base configuration and base extensions working correctly)

On Wed, Sep 9, 2015 at 3:17 PM, jcb91 notifications@github.com wrote:

@dartdog https://github.com/dartdog looks to me from jupyter/notebook#389 https://github.com/jupyter/notebook/issues/389 like this is ready to close too?

— Reply to this email directly or view it on GitHub https://github.com/ipython-contrib/IPython-notebook-extensions/issues/282#issuecomment-139034372 .

Tom Brander http://tombrander.com -Real Estate http://oswco.com -Open Software 3763 West Jackson Blvd. Birmingham, AL 35213 Phone 205-267-1089 @dartdog

jcb91 commented 9 years ago

OK, @juhasch, could you close this? @dartdog, feel free (of course) to open separate issues for each of the extensions you find which don't work :)