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

Jupytext menu not working and out of date documentation for installation process #630

Closed
bxsx opened this issue Sep 22, 2020 · 6 comments
Closed

Comments

@bxsx
Copy link

bxsx commented Sep 22, 2020

Hi,

I have followed the instructions from: https://jupytext.readthedocs.io/en/latest/install.html

1. Jupytext’s contents manager

After installation and building the extension I get this in log output:
[I 15:47:54.105 LabApp] [Jupytext Server Extension] Deriving a JupytextContentsManager from LargeFileManager

In the the documentation: [I 10:28:31.646 LabApp] [Jupytext Server Extension] Changing NotebookApp.contents_manager_class from LargeFileManager to jupytext.TextFileContentsManager

Also this part is out of date, from the documentation: Set c.NotebookApp.contents_manager_class and c.LabApp.contents_manager_class to jupytext.TextFileContentsManager.
Now I get this in output:
[I 15:52:53.456 LabApp] [Jupytext Server Extension] NotebookApp.contents_manager_class is (a subclass of) jupytext.TextFileContentsManager already - OK

2. Jupytext menu in Jupyter Notebook

Not working automatically. Not working after the following commands:

$ jupyter nbextension install --py jupytext
Installing /Users/user/.pyenv/versions/3.8.5/envs/py3apps/lib/python3.8/site-packages/jupytext/nbextension -> jupytext
Making directory: /usr/local/share/jupyter/nbextensions/jupytext/
Copying: /Users/user/.pyenv/versions/3.8.5/envs/py3apps/lib/python3.8/site-packages/jupytext/nbextension/index.js -> /usr/local/share/jupyter/nbextensions/jupytext/index.js
Copying: /Users/user/.pyenv/versions/3.8.5/envs/py3apps/lib/python3.8/site-packages/jupytext/nbextension/jupytext.yml -> /usr/local/share/jupyter/nbextensions/jupytext/jupytext.yml
Copying: /Users/user/.pyenv/versions/3.8.5/envs/py3apps/lib/python3.8/site-packages/jupytext/nbextension/README.md -> /usr/local/share/jupyter/nbextensions/jupytext/README.md
Copying: /Users/user/.pyenv/versions/3.8.5/envs/py3apps/lib/python3.8/site-packages/jupytext/nbextension/jupytext_menu.png -> /usr/local/share/jupyter/nbextensions/jupytext/jupytext_menu.png
- Validating: OK

    To initialize this nbextension in the browser every time the notebook (or other app) loads:

          jupyter nbextension enable jupytext --py

$ jupyter nbextension enable --py jupytext
Enabling notebook extension jupytext/index...
      - Validating: OK
@mwouts
Copy link
Owner

mwouts commented Sep 22, 2020

Hi @bartskowron , thank you for the report. I'll take care of updating the documentation, good point!

I'm sorry to see you struggle with the package installation. Jupytext is a Python package that comes with three Jupyter extensions, but in some cases (e.g. pip install jupytext --user, see #546), the extensions are not automatically installed.

From what I see above you now have the contents manager activated (i.e. the notebook icon on text documents). You also activated the notebook extension in the right way, so I don't see why you don't have the menu yet. May I ask if you have successfully installed any other notebook extension?

Also hopefully this can help:

  1. Maybe you can try installing the menu in --user mode:
jupyter nbextension install --py jupytext --user
jupyter nbextension enable --py jupytext --user
  1. Did you consider using conda? In my experience it works very well and you would not have this kind of troubles any more. Use conda env create/update --file environment.yml with a file inspired from https://github.com/mwouts/jupytext/blob/master/environment-ci.yml

@bxsx
Copy link
Author

bxsx commented Sep 22, 2020

Hi @mwouts and thanks for the quick response. I appreciate it!

I'm sorry to see you struggle with the package installation. Jupytext is a Python package that comes with three Jupyter extensions, but in some cases (e.g. pip install jupytext --user, see #546), the extensions are not automatically installed.

I installed it via pip install jupytext without --user argument.

From what I see above you now have the contents manager activated (i.e. the notebook icon on text documents). You also activated the notebook extension in the right way, so I don't see why you don't have the menu yet.

As I said. After installing jupytext via pip, 2 of 3 extensions are working correctly. I actually forgot to say in the first post that content manager is working even without setting up the jupytext.TextFileContentsManager value - so no extra activation was needed.

I barely believe that this is installation issue. Everything was fine and done automatically. The only problem is with the menu extension.

May I ask if you have successfully installed any other notebook extension?

I tried one other extension and it was working fine.

  1. Maybe you can try installing the menu in --user mode:

I may try it if there is no other options.

  1. Did you consider using conda? In my experience it works very well and you would not have this kind of troubles any more. Use conda env create/update --file environment.yml with a file inspired from https://github.com/mwouts/jupytext/blob/master/environment-ci.yml

No, I don't use conda. And I would really not to be forced to use yet another package manager as for now it would be used only for this particular package.

Anyway, just for clarification:

My versions:

  • jupytext - v1.6.0
  • jupyterlab - v2.2.8

Could you please tell me where exactly the extension should be installed? I may take a look at the directories and verify if the installation was successful. Is there any log that I can verify which extensions are loaded by Jupyter? I tried to use jupyter lab --debug but there was no additional information about extensions.

@mwouts
Copy link
Owner

mwouts commented Sep 22, 2020

Could you please tell me where exactly the extension should be installed?

Well it depends on your Python/Jupyter install. Run jupyter --paths and you will get an idea of all the possible destinations 😄

In my latest conda env the extensions are at the following locations:

(jupytext-demo) marc@zenbook:~$ jupyter serverextension list
Config option `kernel_spec_manager_class` not recognized by `ListServerExtensionsApp`.
config dir: /home/marc/miniconda3/envs/jupytext-demo/etc/jupyter
    jupyterlab  enabled 
    - Validating...
      jupyterlab 2.2.6 OK
    jupytext  enabled 
    - Validating...
      jupytext 1.6.0 OK

(jupytext-demo) marc@zenbook:~$ jupyter nbextension list
Config option `kernel_spec_manager_class` not recognized by `ListNBExtensionsApp`.
Known nbextensions:
  config dir: /home/marc/miniconda3/envs/jupytext-demo/etc/jupyter/nbconfig
    notebook section
      jupytext/index  enabled 
      - Validating: OK
      plotlywidget/extension  enabled 
      - Validating: OK
      jupyter-js-widgets/extension  enabled 
      - Validating: OK

(jupytext-demo) marc@zenbook:~$ jupyter labextension list
Config option `kernel_spec_manager_class` not recognized by `ListLabExtensionsApp`.
JupyterLab v2.2.6
Known labextensions:
   app dir: /home/marc/miniconda3/envs/jupytext-demo/share/jupyter/lab
        jupyterlab-jupytext v1.2.1  enabled  OK

@bxsx
Copy link
Author

bxsx commented Sep 22, 2020

Thanks for the outputs!
I see few differences if compared to mine.

  1. You run older Jupyterlab (2.2.6), I run newer 2.2.8. So it's possible that it can stop working for you too once you upgrade the Jupyter ;-)
  2. My jupytext/index is doubled:
❯ jupyter nbextension list
Known nbextensions:
  config dir: /Users/user/.jupyter/nbconfig
    notebook section
      jupytext/index  enabled
      - Validating: OK
  config dir: /Users/user/.pyenv/versions/3.8.5/envs/py3apps/etc/jupyter/nbconfig
    notebook section
      jupytext/index  enabled
      - Validating: OK

The $HOME/.jupyter/nbconfig contains notebook.json file, while $HOME/.pyenv/versions/3.8.5/envs/py3apps/etc/jupyter/nbconfig contains the file in a notebook.d subdirectory. Both have the same context:

{
  "load_extensions": {
    "jupytext/index": true
  }
}

I guess they are doubled as one copy (under the virtualenv path) was installed automatically while installing Jupytext. The another copy was installed manually as described in #630 (comment) (there is missing EOL in the file BTW.).

I think, I'm going to wait with further investigation until you will upgrade Jupyter yourself first ;) It clearly shows that everything was installed correctly in the first place (via pip).

@mwouts
Copy link
Owner

mwouts commented Sep 23, 2020

You run older Jupyterlab (2.2.6), I run newer 2.2.8. So it's possible that it can stop working for you too once you upgrade the Jupyter ;-)

Well the menu is for Jupyter Notebook, not lab

there is missing EOL in the file BTW.

Feel free to submit a PR on https://github.com/mwouts/jupytext/blob/master/jupyter-config/ (a bit surprising, the pre-commit hook should have fixed that)

Is there any log that I can verify which extensions are loaded by Jupyter?

Go to the notebook interface, not lab, open a notebook, open the browser logs, and search for something like this:
image

If that does not solve it, I recommend that you install the collection of notebook extension: https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/install.html . In particular they provide a UI in which you can select which extension should be activated (and Jupytext should appear as one of them when it is installed).

@bxsx
Copy link
Author

bxsx commented Sep 27, 2020

Well the menu is for Jupyter Notebook, not lab

This solves the problem! ;-)

there is missing EOL in the file BTW.
Feel free to submit a PR on https://github.com/mwouts/jupytext/blob/master/jupyter-config/ (a bit surprising, the pre-commit hook should have fixed that)

After investigation it looks like a Jupyter bug. The jupyter-config files are correct, however while using jupyter nbextenstion install --py jupytext it just copies the content of the file into .jupyter/nbconfig/notebook.json where outer {} brackets are already existing with a missing EOL.

After uninstallation via jupyter nbextension uninstall -py jupytext the .jupyter/nbconfig/notebook.json contains only {} (with missing EOL).

@bxsx bxsx closed this as completed Sep 27, 2020
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

2 participants