Adding jupyter_nbextensions_configurator to Jupyter Notebook - jupyter-notebook

Ultimately, I want a Notebook extension that has spell check. Following this tutorial I tried to install the jupyter_nbextensions_configurator
However, it doesn't seem to have been enabled as I never see the "Nbextensions" tab as promised.
Steps I took:
Installed pip package
pip install jupyter_nbextensions_configurator
Enabled the server extension with the command:
➜ jupyter nbextensions_configurator enable --user # can be skipped for notebook >=5.3
Enabling: jupyter_nbextensions_configurator
- Writing config: /home/hofbr/.jupyter
- Validating...
jupyter_nbextensions_configurator 0.6.1 OK
Enabling notebook nbextension nbextensions_configurator/config_menu/main...
Enabling tree nbextension nbextensions_configurator/tree_tab/main...
Refreshed my .zshrc
Yet, when opening up a fresh notebook (after shutting down all other jupyter environments) I still never see this fabled Nbextensions tab.

Related

Jupyter notebook extensions tab not showing up using poetry as dependency manager

I am using poetry as my dependency manager and the extensions tab is not showing up when I launch jupyter notebooks. How do I get the tab to show up?
My pyproject.toml has these dependencies
[tool.poetry.dependencies]
python = ">=3.8,<3.11"
ipython = "^8.10.0"
jupyter = "^1.0.0"
jupyter-contrib-nbextensions = "^0.7.0"
And I ran
poetry run jupyter contrib nbextension install --user
poetry run jupyter nbextensions_configurator enable --user
poetry run jupyter notebook
But there's no extensions tab:
screenshot of jupyter notebook UI.
The poetry-installed jupyter notebook version is 6.5.2 and my poetry version is 1.2.2.
As an aside, I'm also wondering how to add extensions from the command line. I know the command is poetry run jupyter nbextension enable <nbextension> but, in general, where can I find the <nbextension>? E.g., for "Snippets Menu", what's the <nbextension>?
Thanks!

jupyter-lab does not load jupyter_nbextensions_configurator (but jupyter-notebook does)

Having failed to resolve this after a day and a half of solid effort, I feel I am losing my mind: I have checked config files, rebuilt environments half-a-dozen times, enabled everything possibly relevant, consulted numerous S.O. posts, & github issues and I still can't get it to work.
I want to use certain non-core notebook extensions - and be able to debug using xeus-python (in an environment set up for TensorFlow with CUDA - this part at least has always been OK)
I have tried numerous combinations of python versions, notebook, conda/pip for installation of jupyter etc. but jupyter-lab will not load jupyter_nbextensions_configurator.
However! I discovered by accident that jupyter-notebook does load it (see line 4) - and suddenly I have something to hang a question on. When I run jupyter-notebook, the output begins...
(TF250_PY3810_xeus) A:\My Documents\IT\Programming\Python\Perceptilabs\Batch Files & Shortcuts>jupyter-notebook
[I 10:54:00.733 NotebookApp] Writing notebook server cookie secret to C:\Users\Julian\AppData\Roaming\jupyter\runtime\notebook_cookie_secret
[W 10:54:00.992 NotebookApp] All authentication is disabled. Anyone who can connect to this server will be able to run code.
[I 10:54:01.017 NotebookApp] [jupyter_nbextensions_configurator] enabled 0.4.1
[W 2021-07-01 10:54:01.703 LabApp] 'notebook_dir' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-07-01 10:54:01.704 LabApp] 'password_required' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-07-01 10:54:01.704 LabApp] 'token' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[I 2021-07-01 10:54:01.712 LabApp] JupyterLab extension loaded from C:\Users\Julian\anaconda3\envs\TF250_PY3810_xeus\lib\site-packages\jupyterlab
[I 2021-07-01 10:54:01.712 LabApp] JupyterLab application directory is C:\Users\Julian\anaconda3\envs\TF250_PY3810_xeus\share\jupyter\lab
[I 10:54:01.717 NotebookApp] Serving notebooks from local directory: A:/My Documents
[I 10:54:01.718 NotebookApp] Jupyter Notebook 6.1.1 is running at:
[I 10:54:01.718 NotebookApp] http://localhost:8888/
[I 10:54:01.718 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
(Unfortunately, the debugger seems unavailable in jupyter notebook and ipyfilechooser seemed not to work - note that ipyfilechooser does work in the same environment under jupyter lab!)
Question!
Given this, why isn't jupyter_nbextensions_configurator loaded by jupyter-lab and how do I fix it?
I used a specific notebook version in the end but have no idea whether this is in fact important, since the discovery action was not performed before... but I do wonder whether a specific jupyter version might also be required.
(Side issue/bonus question: why are lab & notebook behaviours different in other ways too e.g. debugger, ipyfilechooser?)
Addtional Info
System: Win 10, 64-bit
I also tried explicitly using
jupyter nbextensions_configurator enable --user/--system/--sys-prefix
even if I used the conda installation that should have taken care of this. Obviously to no avail.
The environment in which is created by (silent, no prompts) batch file as follows (most non-functional content stripped out for posting):
set envName=TF250_PY3810_xeus
echo Conda stuff - create and activate environment %envName%, add xeus-python and cuda support
call conda create -y --name %envName% python==3.8.10
call C:\Users\Julian\anaconda3\Scripts\activate.bat %envName%
call conda install -y -c conda-forge xeus-python
call conda install -y -c conda-forge cudatoolkit=11.2.2
call conda install -y -c conda-forge cudnn=8.1.0.77
echo Conda stuff - install jupyterlab, notebook (versioned!), extensions stuff
call conda install -y -c conda-forge jupyterlab notebook==6.1.1
call conda install -y -c conda-forge jupyter_nbextensions_configurator
call conda install -y -c conda-forge jupyter_contrib_nbextensions
#REM pip installations. NB tensorflow_decision_forests is linux only 30/06/2021 so can't install yet
echo Pip stuff - install TensorFlow, seaborn, etc.
pip install -q --upgrade pip setuptools
pip install -q --no-input tensorflow-gpu==2.5.0 tensorflow-probability tensorflow-addons
pip install -q --no-input seaborn tabulate pandoc
pip install -q ipyfilechooser tqdm
#REM Alternative jupyter PIP setup.
#REM pip install -q jupyterlab jupyter_nbextensions_configurator jupyter_contrib_nbextensions
#REM jupyter contrib nbextension install --user
#REM jupyter nbextensions_configurator enable --user
#REM jupyter lab

How to install a nbextension with python and js components as a labextension

I created a nb extension following this link!. The extension works correctly when ran from:
jupyter notebook
When I ran the same extension from
jupyter lab
The extension does not work and gives me an error:
Error displaying widget: model not found
Here is the error on console:
Could not instantiate widget
(anonymous) # manager-base.js:273
09:27:26.891 default.js:127 Error: Module test_pp, semver range 1.2.0 is not registered as a widget module
at WidgetManager.loadClass (manager.js:251)
test_pp is the extension module I am trying to run.
Following are the commands that make the extension work in notebok:
python setup.py build
pip install -e .
jupyter nbextension install --py test_pp
jupyter nbextension enable --py test_pp
jupyter notebook
Folder structure of notebook extension:
test_pp
js
lib
embed.js
extension.js
index.js
labplugin.js
test_pp.js <------ The javascript part of extension
node_modules
package.json
webpack.config.js
test_pp
static
__init__.py
_version.py
test_pp.py <-------- The extension server side python
Looking thru several tutorials and blogs I found some commands that I could run that should make it but, but they did not help:
pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension
jupyter labextension install #jupyter-widgets/jupyterlab-manager
cd jupyter_lab_src/test_pp
jupyter labextension install . <----- Fails, not a valid npm package
cd js <----- as that folder has package.json
jupyter labextension install . <---- installs successfully
jupyter lab
Open a notebook from lab, call the same commands that work in jupyter notebook:
from test_pp import test_pp
pp = test_pp.PostProcessor()
pp.initWidget()
data = 1
pp.set_data(data)
pp
Gives the error I described above. Ran a command to see the extensions:
(base) C:\data\OnScale_Jupyter\jupyterlab\test_pp>jupyter labextension list
JupyterLab v1.1.3
Known labextensions:
app dir: c:\users\anils\miniconda3\share\jupyter\lab
#jupyter-widgets/jupyterlab-manager v1.0.2 enabled ok
test_pp v0.1.0 enabled ok* <----- why is there a star
local extensions:
test_pp: C:\data\OnScale_Jupyter\jupyterlab\test_pp\js
I see an error on the conda command console as well:
[W 10:22:31.781 LabApp] Failed to fetch package metadata for 'test_pp': <HTTPError 404: 'Not Found'>
I believe, in essence, I am unsure of how to launch a nbextension as a labextension?
Any help would be appreciated?
Previously, I had the same issue. Here is what I did.
First, I installed the nbextension using the command in conda prompt.
(https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/install.html)
Then I enabled hinterland in nbextension in jupyternotebook. But still, it doesn't work in jupyter lab.
Then I followed instructions mentioned in this link:
https://jupyterlab.readthedocs.io/en/stable/user/extensions.html#id14
installed nodejs using the below command:
conda install -c conda-forge nodejs
Then I rebuild my jupyterlab using the command:
jupyter lab build
Then I could see docstring and other autofill extension working in jupyterlab, as in this image.

How to install variable explorer extension in jupyter notebook

I am running jupyter notebook through Anaconda Navigator.
I tried installing variable explorer extension,
Although I was successful in installing the extension but I am not able to install its java and css dependencies
! pip install jupyter_contrib_nbextensions
This works , however this doesn't works
jupyter contrib nbextension install --user
Any help will be apreciated
Can you give it a try by using command:
jupyter nbextension enable varInspector/main
It worked for me.

Jupyter nbextensions does not appear

I tried to install jupyter_contrib_nbextensions : http://jupyter-contrib-nbextensions.readthedocs.io/en/latest/install.html
Everything worked fine but when I open a notebook nothing changes. I can't see the new tool bar that I'm supposed to see.
When I reinstall the Extension, the process is the same (I don't have a message tellign me that the files already exists). I don't have an error. So I can't figure out why it doesn't work.
Thanks a lot.
Follow 3 steps: In Terminal
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
jupyter nbextension enable varInspector/main
after this you will see "Vaildating: ok"
Now you can open jupyter notebook you will see the require changes
Update Jan 2021
I was seeing this issue using the latest from pip packages.
Turns out it was related to:
https://discourse.jupyter.org/t/the-static-notebook-js-mathjaxutils-js-is-missing/7303
Basically, jupyter-notebook moved a .js file in a recent update causing the extensions tab to no longer appear.
Reverting to an older version works-around the issue:
pip install notebook==6.1.5
Also note that a substantial number of the extensions aren't officially supported by the 6.x version. So you may be better off reverting to 5.x until your desired extensions are 'officially' supported:
pip install notebook==5.7.10
Following are the commands which installs the jupyter nb_extensions
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
The second command might give you below error:
jupyter contrib not found
Above command can be resolved as below:
- open cmd to install manually
cd .\Python\<your-python-version>\Lib\site-packages\jupyter_contrib_nbextensions
python application.py install
- Restart the jupyter notebook server
Note: Also make sure that your packages jupyter , notebook and your jupyter_contrib_nbextensions are installed for same version of python (and same --user if you have installed all your packages with --user flag)
First, follow this SO-post (go to the update) to install the extension.
Then shutdown the notebook server.
Then type $ jupyter nbextension enable varInspector/main.
If it says OK, you can start your notebook and should see the crosshair.
try to run this
jupyter contrib nbextension install --user
then relaunch the Jupyter notebook.
this might solve the problem as it did for me.
Try this out ->
1)Open Anaconda Prompt.
2)Type in -
conda install -c conda-forge jupyter_contrib_nbextensions
(if c is the default directory)
3)Proceed with the installation.
4)Exit the Anacodna prompt.
5)Relaunch Jupyter notebook.
(You will now see nbextensions tab)
Following steps with Anaconda Prompt ->
1)Open Anaconda Prompt.
2)Type in -
conda install -c conda-forge jupyter_contrib_nbextensions
Enter 'y' for installation.
type in jupyter contrib nbextension install --sys-prefix
4)Exit the Anacodna prompt.
5)Relaunch Jupyter notebook. (You will now see nbextensions tab)
Screenshot of my installation
1 quick info -
1. even after enabling nbextensions, from the notebooks tree page,
2. you need to activate it on your Jupyter notebook.
See below.
Running following command one by one !!!
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
jupyter nbextension enable spellchecker/main
jupyter nbextension enable codefolding/main
Posting this solution because it took me 20 minutes to figure out why my interface looked so different from all of the screenshots everyone else was posting. I hope it can prevent some other soul from making the same mistake I did:
I was running my Jupyter Notebook with the command jupyter-lab instead of jupyter notebook. I understand there are functional differences between the two, but in my case having spellcheck was much more important than any of the difference the two provided. As soon as I used jupyter notebook instead, it worked perfectly.
UPDATE, FEBRUARY 2023:
I first installed nbextensions using pip. Then I couldn't run the second command jupyter contrib nbextension install --user as the others and got the error Exception: Jupyter command 'jupyter-contrib' not found.
So, I tried installing using conda with this command:
conda install -c conda-forge jupyter_contrib_nbextensions
NOTE 1: I had to run my Anaconda prompt in "Administration Mode" in order to be able to install using conda.
After that I could run the second command:
jupyter contrib nbextension install --user
And it's working now.
NOTE 2: I'm using the latest version of anaconda so I DID NOT need to revert my jupyter version as mentioned here.
Downgrading the notebook version to 5.6.0 worked for me.
pip install notebook==5.6.0
If this doesn't work for you, then return to your original version.
Good luck.
I followed the highest voted answer to install the nbextensions but received an error when I reboot the Jupyter Notebook:
404 GET /nbextensions/nbextensions_configurator/tree_tab/main.js?v=20220513151408
It seemed that what I've installed can not be found by Jupyter Notebook.
After checking the detailed installation log in the terminal, I found Nbextension has been installed into the python2.7 directory:
./Library/Python/2.7/lib/python/site-packages (from jupyter_contrib_nbextensions)
I am currently using Python 3 in Jupyter Notebook so I decided to uninstall what I have and reinstall Nbextension using pip3 instead of pip. Then I reboot Jupyter Notebook and saw the Nbextensions tab (next to the tab Clusters)!
In sum, based on my attempt, I would recommend using pip3 instead of pip to avoid an installation in Python 2 directory.
My installed package version (windows 11):
notebook 6.5.2
jupyter-contrib-nbextensions 0.7.0
jupyter-nbextensions-configurator 0.6.1
Though I can not get the nbextensions menu tab out using the methods mentioned in the previous try outs of this post, I can still use the jupyter nbextension enable <require path> command in the ../python3/scripts folder as following examples which I use frequently:
jupyter nbextension enable varInspector/main
jupyter nbextension enable toc2/main
jupyter nbextension enable execute_time/ExecuteTime
jupyter nbextension enable hide_input/main
jupyter nbextension enable splitcell/splitcell
jupyter nbextension enable code_prettify/code_prettify
Then the variable inspector, table of contents, split cell, hide inputs and code prettify buttons appear in the notebook page. Other extensions can be tried replacing command's <require path> which can be found under the older version's notebook extensions tab that doesn't have the problem.
Change old path notebook/js/mathjaxutils to base/js/mathjaxutils.js to load the dependency correctly.
This solve my problem.
For details see this Github issue about this bug.

Resources