TOC doesnt load?
diego898 opened this issue · 26 comments
Hello,
I am on windows running the conda suite of packages and have ipython 2.3.1. I ahve followed the steps for the table of contents, placing
$([IPython.events]).on("app_initialized.NotebookApp", function () {
IPython.load_extensions("toc");
});
in my C:\Users\diego\.ipython\profile_default\static\custom\custom.js
file. I restart ipython and do not see any indication that the TOC extension is working.
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");
});
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
I think it depends on the IPython version which mode of loading you choose.
@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.
This extension only works with IPython 3.x
IPython version 3.x, not Python 3. There is no IPython 3.4 yet.
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 :-(
same here.
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.
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
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.
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
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
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\
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 ...
Nope, the reboot didn't work. Dang, this is frustrating ...
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.
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:
-
Set
JUPYTER_CONFIG_DIR
andJUPYTER_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
-
Install nbextensions by cloning the git repository and running
python setup.py install
. -
Open a notebook using
jupyter notebook
, and activate some nbextensions by navigating to thehttp://localhost:8888/nbextensions/
page. This should create annotebook.json
file in your$JUPYTER_CONFIG_DIR/nbconfig/
directory. -
Move
toc.js
andtoc.css
files to the$JUPYTER_DATA_DIR/nbextensions/usability/toc
folder, and add a line"usability/toc/toc": true
to yournotebook.json
file.
Restart your notebook, and everything should work!
@ostrokach I don't have a ~/.jupyter/data directory!
@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.
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?
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.
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