Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extension not working with notebook 6.5.2 #1628

Closed
rhajou opened this issue Feb 7, 2023 · 10 comments
Closed

extension not working with notebook 6.5.2 #1628

rhajou opened this issue Feb 7, 2023 · 10 comments

Comments

@rhajou
Copy link

rhajou commented Feb 7, 2023

Hello,

I am trying to install jupyter_contrib_nb_extensions in my venv environment with the following versions:

  • notebook version: 6.5.2
  • python: 3.9
  • jupyter_contrib_nbextensions: 0.7.0

using these commands for the installtion of jupyter_contrib_nbextensions:

  • pip install jupyter_contrib_nbextensions
  • jupyter contrib nbextension install --user (and I even tried with --sys-prefix)

But the extensions would not appear in jupyter notebook. I tried reloading the venv environment (deactivate/activate) reload vs code, reload multiple times the jupyter notebook server and it didn't work.

The only solution that worked is downgrading notebook from 6.5.2 to 5.6.0

@mforbes
Copy link

mforbes commented Feb 20, 2023

Confirmed: with notebook 6.5.2, the Nbextensions dashboard menu does not appear. This is particularly problematic for my MacBook Pro on ARM because there is no native option to downgrade to 5.6.0 using Conda. (I could do this under Rosetta, but this is a pain.)

I was a little confused between jupyter_contrib_nbextensions and jupyter_nbextensions_configurator. I am able to activate some extensions (I tested jupyter-black) with notebook==6.5.2, jupyter_contrib_nbextensions==0.7.0, and python==3.10.9 as follows:

conda create -y -n tst -c conda-forge jupyter_contrib_nbextensions black jupyter-black
conda activate tst
jupyter nbextension enable jupyter-black-master/jupyter-black

or

conda create -y -n tst "python~=3.10"
conda activate tst
pip install  jupyter_contrib_nbextensions black
jupyter nbextension install https://github.com/drillan/jupyter-black/archive/master.zip --sys-prefix
jupyter nbextension enable jupyter-black-master/jupyter-black

but still get a lot of validation errors and no visible configurator (visiting :

$ jupyter nbextension list
Known nbextensions:
  config dir: /Users/mforbes/.conda/envs/tst/etc/jupyter/nbconfig
    notebook section
      nbextensions_configurator/config_menu/main  enabled 
      - Validating: problems found:
        - require?  X nbextensions_configurator/config_menu/main
      contrib_nbextensions_help_item/main  enabled 
      - Validating: OK
    tree section
      nbextensions_configurator/tree_tab/main  enabled 
      - Validating: problems found:
        - require?  X nbextensions_configurator/tree_tab/main
  config dir: /Users/mforbes/.jupyter/nbconfig
    notebook section
      jupyter-black-master/jupyter-black  enabled 
      - Validating: OK

Perhaps this is an issue with jupyter_nbextensions_configurator instead? Visiting http://localhost:8888/nbextensions/ give a blank page with the following errors in the JS console:

Javascript console errors
Failed to load resource: the server responded with a status of 404 (Not Found)
localhost/:1 Refused to execute script from 'http://localhost:8888/static/components/marked/lib/marked.js?v=20230220020156' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:168 Uncaught Error: Script error for "components/marked/lib/marked", needed by: nbextensions/nbextensions_configurator/render/render
http://requirejs.org/docs/errors.html#scripterror
    at makeError (require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:168:17)
    at HTMLScriptElement.onScriptError (require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:1735:36)
makeError @ require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:168
onScriptError @ require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:1735
DevTools failed to load source map: Could not load content for chrome-extension://gighmmpiobklfepjocnamgkkbiglidom/browser-polyfill.js.map: System error: net::ERR_FILE_NOT_FOUND

@mwyschan
Copy link

I was also struggling with this problem, so I did a bit of digging.
It has to do with this specific line:

Looking at jupyter/nbclassic#201, we can see that a recent upgrade was done, and marked is now served with a different filename:
https://github.com/jupyter/nbclassic/blob/51b475bdf94e01ce84913800b19559eaf49a7d24/nbclassic/static/base/js/markdown.js#L9
https://github.com/jupyter/nbclassic/blob/51b475bdf94e01ce84913800b19559eaf49a7d24/nbclassic/static/tree/js/notebooklist.js#L14

To fix this problem temporarily, you can make a copy of marked.umd.js with the filename marked.js. If you're working with conda, this file can be found at YOUR_CONDA_INSTALL_LOCATION/envs/YOUR_ENV_NAME/lib/python3.10/site-packages/nbclassic/static/components/marked/lib/marked.umd.js. Haven't used pip in a long time, but it should be a similar path starting from site-packages/....

Hope this helps.

@cmcafee-decentrix
Copy link

I was also struggling with this problem, so I did a bit of digging. It has to do with this specific line:

Looking at jupyter/nbclassic#201, we can see that a recent upgrade was done, and marked is now served with a different filename: https://github.com/jupyter/nbclassic/blob/51b475bdf94e01ce84913800b19559eaf49a7d24/nbclassic/static/base/js/markdown.js#L9 https://github.com/jupyter/nbclassic/blob/51b475bdf94e01ce84913800b19559eaf49a7d24/nbclassic/static/tree/js/notebooklist.js#L14

To fix this problem temporarily, you can make a copy of marked.umd.js with the filename marked.js. If you're working with conda, this file can be found at YOUR_CONDA_INSTALL_LOCATION/envs/YOUR_ENV_NAME/lib/python3.10/site-packages/nbclassic/static/components/marked/lib/marked.umd.js. Haven't used pip in a long time, but it should be a similar path starting from site-packages/....

Hope this helps.
It DID help, thanks a bunch for posting. Chased this one for a couple of hours before stumbling on your post.

@JiankunW
Copy link

JiankunW commented Mar 2, 2023

I was also struggling with this problem, so I did a bit of digging. It has to do with this specific line:

Looking at jupyter/nbclassic#201, we can see that a recent upgrade was done, and marked is now served with a different filename: https://github.com/jupyter/nbclassic/blob/51b475bdf94e01ce84913800b19559eaf49a7d24/nbclassic/static/base/js/markdown.js#L9 https://github.com/jupyter/nbclassic/blob/51b475bdf94e01ce84913800b19559eaf49a7d24/nbclassic/static/tree/js/notebooklist.js#L14

To fix this problem temporarily, you can make a copy of marked.umd.js with the filename marked.js. If you're working with conda, this file can be found at YOUR_CONDA_INSTALL_LOCATION/envs/YOUR_ENV_NAME/lib/python3.10/site-packages/nbclassic/static/components/marked/lib/marked.umd.js. Haven't used pip in a long time, but it should be a similar path starting from site-packages/....

Hope this helps.

I am wondering if you are willing to share a bit more about how you located this bug? I had been struggling with this problem for some time and your solution was very helpful. I would love to learn more about your thought process.

Thanks,
Jiankun

@mwyschan
Copy link

mwyschan commented Mar 2, 2023

It's a bit off-topic, but sure. Note that I had not seen the source code for jupyter_contrib_nbextensions prior to this, so most of this is the result of trial and error.

When you open the notebook page after running jupyter notebook with jupyter_contrib_nbextensions installed, you'll notice that an error occurs in the console window:

[W 17:20:38.083 NotebookApp] 404 GET /static/components/marked/lib/marked.js?v=20230302172027 (127.0.0.1) 11.730000ms referer=http://localhost:8888/tree

404 GET indicates that the notebook page (http://localhost:8888/tree) is requesting for marked.js, but it's not available. static indicates that the resource is local. You can confirm this by opening the Debugger menu in Chrome (or equivalent in Firefox):
image

Indeed, marked.js is missing from the tree of files that are available.

We know that this wasn't a problem until recently, so something resembling marked.js should exist. There's two things we can do:

  1. Look for references to marked. Something on the notebook page is requesting for it, so where is it being requested?
    # CONDA_INSTALL/envs/CONDA_ENV
    $  grep -r "marked" *
    ...
    conda-meta/nbclassic-0.5.2-pyhd8ed1ab_0.json:  "lib/python3.10/site-packages/nbclassic/static/components/marked/lib/marked.umd.js",
    conda-meta/nbclassic-0.5.2-pyhd8ed1ab_0.json:  "_path": "site-packages/nbclassic/static/components/marked/lib/marked.umd.js",
    ...
  2. Look for files called marked.
    # CONDA_INSTALL/envs/CONDA_ENV
    $ find . -name "marked*"
    ./lib/python3.10/site-packages/nbclassic/static/components/marked
    ./lib/python3.10/site-packages/nbclassic/static/components/marked/lib/marked.umd.js
    ./share/qt/3rd_party_licenses/qtwebengine/src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/marked

We've found the path to marked: CONDA_INSTALL/envs/CONDA_ENV/lib/python3.10/site-packages/nbclassic/static/components/marked/lib/marked.umd.js. Looking at the path and comparing it to the path indicated in the 404 GET request, we can reasonably expect that this is where marked.js should also be. marked.umd.js probably contains the content we want, so try making a copy of it as marked.js instead, and it works!

However, the story's not over yet. This is path is unusual, since it belongs to the nbclassic package, not jupyter_contrib_nbextensions. Time to turn to the source code.

Searching for marked in the jupyter_contrib_nbextensions repository on GitHub:
image

Searching for marked in the nbclassic repository on GitHub:
image

...and there's the culprit.

@JiankunW
Copy link

JiankunW commented Mar 3, 2023

Thank you for taking the time to explain your thought process in such detail. Your insights were helpful in understanding how to locate the bug. I really appreciate your willingness to share your expertise and help others in the community. Thanks again!

@dynamicsoar
Copy link

The workaround mentioned above only partly worked for me (the Nbextensions tab was shown but no extensions were actually working). Instead, I trided downgrading nbclassic from 0.5.2 to 0.4.8 by simply $ conda install nbclassic=0.4.8 as per this post: Jupyter-contrib/jupyter_nbextensions_configurator#151 (comment)
It seems everything is working, though not entirely sure if this is the right way...

@mforbes
Copy link

mforbes commented Mar 7, 2023

@dynamicsoar Thanks! This is the key. I believe that the issue lies fully with the configurator (Jupyter-contrib/jupyter_nbextensions_configurator#151) and not with jupyter_contrib_nbextensions. Pinning nbclassic<0.5 resolves the issue, even with notebook 6.5.2 and 6.5.3:

conda create -n tst "python~=3.11"
conda activate tst
pip install jupytext RISE jupyter_contrib_nbextensions black "nbclassic<0.5"

Everything works for me with this. Upgrading nbclassic causes the configurator to break because the upgraded to marked 4.0.10, but jupyter_contrib_nbextensions has not upgraded yet (issue #151).

Perhaps @rhajou could confirm, but I think this issue can be closed: further updates should be tracked there.

@rhajou
Copy link
Author

rhajou commented Mar 7, 2023

@dynamicsoar Thanks! This is the key. I believe that the issue lies fully with the configurator (Jupyter-contrib/jupyter_nbextensions_configurator#151) and not with jupyter_contrib_nbextensions. Pinning nbclassic<0.5 resolves the issue, even with notebook 6.5.2 and 6.5.3:

conda create -n tst "python~=3.11"
conda activate tst
pip install jupytext RISE jupyter_contrib_nbextensions black "nbclassic<0.5"

Everything works for me with this. Upgrading nbclassic causes the configurator to break because the upgraded to marked 4.0.10, but jupyter_contrib_nbextensions has not upgraded yet (issue #151).

Perhaps @rhajou could confirm, but I think this issue can be closed: further updates should be tracked there.

This is the correct way to solve this issue.
I am closing this issue

@tojunfeng
Copy link

it is really helpful, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants