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

Not possible to install hierarchical_collapse #140

Closed carlospgmat03 closed 8 years ago

carlospgmat03 commented 9 years ago

I am almost sure this is not the correct place to ask for help. However, I cannot find other. I want to have the functionality of hierarchical_collapse. However after fighting for several days I only have vague idea of what should be done. Unfortunately I am also new in ipython. I have successfully loaded gist, acording to the console log in chrome, after following the instructions in
https://github.com/ipython-contrib/IPython-notebook-extensions/wiki

I cloned the git@github.com:ipython-contrib/IPython-notebook-extensions.git repository, and copied the but, once I try to do something similar with hierarchical_collapse, it says there is nothing to download. Moreover, in the console, I get a very simple message:

Failed to load extension(s): ["nbextensions/testing/hierarchical_collapse/main.js"] Error: Script error for: nbextensions/testing/hierarchical_collapse/main.js http://requirejs.org/docs/errors.html#scripterror {requireType: "scripterror", requireModules: Array[1], originalError: Event, stack: (...), message: "Script error for: nbextensions/testing/hierarchica…http://requirejs.org/docs/errors.html#scripterror"}

although its there. A similar behaviour with a simpler extension, namely cellstate.js:

Failed to load extension(s): ["nbextensions/testing/cellstate.js"] Error: Script error for: nbextensions/testing/cellstate.js http://requirejs.org/docs/errors.html#scripterror {requireType: "scripterror", requireModules: Array[1], originalError: Event, stack: (...), message: "Script error for: nbextensions/testing/cellstate.j…http://requirejs.org/docs/errors.html#scripterror"}

If you cannot help me here, could you point me to a better place to seek help? Thanks!

juhasch commented 9 years ago

This is the right place to ask such questions. Unfortunately, as you have found out, installing notebook extensions is currently not very user friendly.

First, if you use IPython 2.x (not the Python version), checkout the 2.x branch. This should allow you to load extensions.

The hierarcical collapse extension is quite big and has not been updated for some time. Extensions in the testing directory might or might not work. You can try to contact the author, but there are some open issues on this extension without a reply.

ChristoSilvia commented 9 years ago

Are there additional steps which are necessary to load the 'codefolding' extension? The directory that contains it has many files, do those need to be configured individually?

jat255 commented 9 years ago

I'm not sure if this will help anybody, but after checking out the 2.x branch, I was able to get the hierarchical_collapse extension working with a little tweaking.

First, in your .ipython profile directory (I am using hyperspy, so my profile is in C:\Users\Josh.ipython\profile_hyperspy) make sure that you have a ./static/custom/custom.js file that loads the extension like the following:

require(["base/js/events"], function (events) {
    $([IPython.events]).on("app_initialized.NotebookApp", function () {
        IPython.load_extensions('testing/hierarchical_collapse/main')
    });
 });

After doing this, it still wasn't working. Looking in the Chrome javascript console, I saw that there was an error saying that ./static/custom/testing/hierarchical_collapse/main.css could not be found. For some reason, the extension looks for main.css in the profile directory rather than in the nbextensions directory. By creating that folder and copying main.css from the extension folder to the newly created directory, I was able to get it working (note, I also have the codefolding extension running in these pictures):

unfolded

folded

AlJohri commented 8 years ago

I'm also unable to install this extension on Jupyter 4.x.

jcb91 commented 8 years ago

@AlJohri what steps did you follow to get to the console log you posted? The installation process for extensions in general is fraught with complications, unfortunately. It seems from your console log that you've managed to get a few others working successfully, however, so that's hopeful. How did you install & enable (for example) the init_cell extension? Given that you've got the config_menu extension loading, I guess you've also got the config page loading ok? The hierarchical collapse extension currently doesn't have a yaml file to allow enabling it through the config page, but that might be a simpler route for you to try... In related news, I've made a replacement of hierarchical collapse for my own use, as I wanted the functionality and found it unreliable. I've not published it yet, but if you'd like to try it, I could put it up somewhere.

jcb91 commented 8 years ago

It also seems that an attempt has been made to load the extension in an unlikely location, nbextensions/hierarchical_collapse.js, which, if you're following the repository file structure, wouldn't be a likely place to find it. This leads me to guess that this load attempt was perhaps made from a custom.js file similarly to jat225's description above, but with an edited path?

jcb91 commented 8 years ago

You can also now see my collapsible headings extension at #466.

juhasch commented 8 years ago

Extension replaced by collapsible_headings