Giter VIP home page Giter VIP logo

Comments (26)

ostrokach avatar ostrokach commented on July 22, 2024 1

I got the TOC extension to work in IPython 4 / Jupyter.

It wasn't working following the provided installation instructions, giving the following error in the javascript console:

Loaded extension: toc
Uncaught TypeError: Cannot read property 'load_ipython_extension' of undefined

However, when I moved the toc.js and toc.css files to the .jupyter/data/nbextensions/usability/toc folder, and added a line "usability/toc/toc": true to the .jupyter/nbconfig/notebook.json file, everything worked!

Here are the complete instructions:

  1. Set JUPYTER_CONFIG_DIR and JUPYTER_DATA_DIR environmental variables in ~/.bashrc, so that there are no surprises:

    export JUPYTER_CONFIG_DIR=$HOME/.jupyter
    export JUPYTER_DATA_DIR=$HOME/.jupyter/data
    
  2. Install nbextensions by cloning the git repository and running python setup.py install.

  3. Open a notebook using jupyter notebook, and activate some nbextensions by navigating to the http://localhost:8888/nbextensions/ page. This should create an notebook.json file in your $JUPYTER_CONFIG_DIR/nbconfig/ directory.

  4. Move toc.js and toc.css files to the $JUPYTER_DATA_DIR/nbextensions/usability/toc folder, and add a line "usability/toc/toc": true to your notebook.json file.

Restart your notebook, and everything should work!

from ipython_extensions.

dacoex avatar dacoex commented on July 22, 2024

same with me on anaconda.

but with the following change in custom.js it works:

$([IPython.events]).on("notebook_loaded.Notebook", function () {
    IPython.load_extensions("toc");
});

See also:
http://nbviewer.ipython.org/github/ahambi/140824-TOC/blob/master/A%20floating%20table%20of%20contents.ipynb

from ipython_extensions.

diego898 avatar diego898 commented on July 22, 2024

@dacoex Thanks for the suggestion, but that still doesn't do anything for me. :L

from ipython_extensions.

lo-co avatar lo-co commented on July 22, 2024

Hey @diego898,

I am having a similar issue and the javascript is throwing an odd error. In the function toc_button I get an uncaught type error which states "cannot read property 'toolbar' of type undefined." This is called by load_ipython_extension in toc.js which is the entry point from utils.js.

Hopefully this points to the problem source.

Cheers, Matt

from ipython_extensions.

dacoex avatar dacoex commented on July 22, 2024

I think it depends on the IPython version which mode of loading you choose.

from ipython_extensions.

diego898 avatar diego898 commented on July 22, 2024

@dacoex I've tried both methods: the one in the readme and hte one you suggested with ipython version: 2.3.1 and I couldnt anything to show up.

from ipython_extensions.

minrk avatar minrk commented on July 22, 2024

This extension only works with IPython 3.x

from ipython_extensions.

lo-co avatar lo-co commented on July 22, 2024

@minrk - I am using 3.4 and still have the same error...

from ipython_extensions.

minrk avatar minrk commented on July 22, 2024

IPython version 3.x, not Python 3. There is no IPython 3.4 yet.

from ipython_extensions.

dreme avatar dreme commented on July 22, 2024

Is there an archived version of the TOC extension that works for IPython 2.3.x (or 2.4.x)?
It used to work fine for me on my anaconda distribution, but has now stopped working. It's a great extension and I'm really missing it :-(

from ipython_extensions.

diego898 avatar diego898 commented on July 22, 2024

same here.

from ipython_extensions.

lo-co avatar lo-co commented on July 22, 2024

Thanks, @minrk.... I was looking a the python distribution, not the ipython version. I am going to second @dreme - I can not seem to upgrade to the current development version of ipython (Window's 8).

from ipython_extensions.

minrk avatar minrk commented on July 22, 2024

The 2.x branch of this repo marks the last commit before 3.x changes started happening. There may have been fixes since then that aren't backported.

https://github.com/minrk/ipython_extensions/tree/2.x

If you have fixes for 2.x, feel free to make PRs against that branch.

from ipython_extensions.

diego898 avatar diego898 commented on July 22, 2024

thanks @minrk !

The following works for me:

curl https://raw.githubusercontent.com/minrk/ipython_extensions/2.x/nbextensions/toc.js > $(ipython locate)/nbextensions/toc.js
curl https://raw.githubusercontent.com/minrk/ipython_extensions/2.x/nbextensions/toc.css > $(ipython locate)/nbextensions/toc.css

and IPython.load_extensions('toc'); in my custom.js

from ipython_extensions.

dreme avatar dreme commented on July 22, 2024

Thanks minrk for the pointer to the 2.x branch, and good to see that it works for diego.

Sadly, it is still not working for me. Can I check with you guys that I'm putting the appropriate files in the right folders. I have an anaconda python distro on windows 7 and my .ipython folder sits in my home folder:

  • 2.x versions of toc.css and toc.js files in the .ipython/nbextensions folder
  • custom.js file (with dacoex's suggested loading script) in the .ipython\profile_default\static\custom folder

I'm having the same problem in Chrome and Firefox, so don't think it is browser related.

from ipython_extensions.

diego898 avatar diego898 commented on July 22, 2024

I have anaconda on windows 8. My custom.js is in:
I have IPython.load_extensions('toc'); in: C:\Users\diego\.ipython\profile_default\static\custom\custom.js

Some notes:

  • make sure you used the commands I pasted above to make sure you're grabbing the 2.x versions.
  • after installing them, I shut down ipython, restarted chrome and restarted ipython

from ipython_extensions.

dreme avatar dreme commented on July 22, 2024

Thanks Diego, I've just been doing a 'copy and paste' from minrk's github pages to get the toc.css and toc.js scripts.

How did you execute the curl command in Windows, as it doesn't work in the windows cmd shell

from ipython_extensions.

diego898 avatar diego898 commented on July 22, 2024

I ran it using git bash. You can also just download them using these links:

https://raw.githubusercontent.com/minrk/ipython_extensions/2.x/nbextensions/toc.js
https://raw.githubusercontent.com/minrk/ipython_extensions/2.x/nbextensions/toc.css

and place them manually in: C:\Users\YOURNAME\.ipython\nbextensions\

from ipython_extensions.

dreme avatar dreme commented on July 22, 2024

Thanks Diego.

I've used Git Shell to execute the curl commands for downloading the 2.x toc.css and toc.js files, and put them in the nbextensions folder, and also updated my custom.js file. I also shut down the ipython notebook server and my browser.

But unfortunately the TOC extension still doesn't load.

I'll try rebooting my computer to see if that helps ...

from ipython_extensions.

dreme avatar dreme commented on July 22, 2024

Nope, the reboot didn't work. Dang, this is frustrating ...

from ipython_extensions.

diego898 avatar diego898 commented on July 22, 2024

Hello! @minrk unexpectedly this problem reappeared for me today, even though it was working for me after I upgraded to ipython 3.x

It was working fine, but today it wont load anymore though I have all the files in place and have placed the loading snippet in custom.js

EDIT: restarting ipython+chrome wasnt enough. I had to restart the computer then the TOC appeared.

from ipython_extensions.

diego898 avatar diego898 commented on July 22, 2024

@ostrokach I don't have a ~/.jupyter/data directory!

from ipython_extensions.

ostrokach avatar ostrokach commented on July 22, 2024

@diego898 The default JUPYTER_DATA_DIR is platform specific. You can see what it is on your system using the command:

python -c "from jupyter_core.paths import jupyter_data_dir; print(jupyter_data_dir());"

You can change it to whatever you like by exporting the JUPYTER_DATA_DIR environment variable. I saw someone else doing export JUPYTER_DATA_DIR=$JUPYTER_CONFIG_DIR/data in their ~/.bashrc, and I liked that idea because it's much more consistent with how IPython did things.

Either way, that folder may be empty until you install nbextensions.

For more info, see here: http://jupyter-core.readthedocs.org/en/latest/paths.html.

from ipython_extensions.

dreme avatar dreme commented on July 22, 2024

Hi @ostrokach, thanks for your instructions on getting the TOC extension to work in IPython 4 / Jupyter

I'm trying to apply them for a Win7 python anaconda installation. Unfortunately I get stuck on your first instruction for installing nbextensions, using:

conda install -c http://conda.anaconda.org/juhasch nbextensions

Unfortunately this leads to the following error:

Fetching package metadata: ......
Solving package specifications: .............
Error: Unsatisfiable package specifications.
Generating hint:
Hint: the following packages conflict with each other:
   - nbextensions
   - python 2.7*
Use 'conda info nbextensions' etc. to see the dependencies for each package.
Note that the following features are enabled:
  - vc9

Any ideas?

from ipython_extensions.

ostrokach avatar ostrokach commented on July 22, 2024

Hey @dreme,

You are getting that error because you are using Python 2.7 and the juhasch anaconda channel has nbextension binaries only for Python 3.4 (see https://anaconda.org/juhasch/nbextensions/files).
You should download nbextensions from github (press the Download ZIP button, or clone the repository using git), and install it by typing python setup.py install.

I never use windows so can't give you more help than that.

from ipython_extensions.

dreme avatar dreme commented on July 22, 2024

Hi @ostrokach, thank you very much. I now have the TOC extension working, along with a whole heap of other goodies in the notebook extension package that you kindly referred me to

from ipython_extensions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.