jupytext: Extension not loading in jupyterlab 3

In Jupyterlab 3.0.4 with Jupytext 1.9.1 on Ubuntu 20.04.1 LTS the filemanager does not appear to be loading. Specifically the log line that says the jupytext file manager loads in not showing up. I can use the console commands to pair a notebook but no additional files are saved. The GUI also does not show previously paired files as notebooks either.

I can use the most recent version of jupytext with jupyter notebook just fine. I can also downgrade to lab 2.2 and the old plugin and it works fine as well.

I have tried all variations of enabling and configuration files listed in the install documentation and nothing has worked. I am fairly sure there is a bug here but there’s no error message so it is a bit hard to say.

Let me know if there’s any more information I can provide.

Here’s a little bit of additional debug info:

g@g-ThinkPad-P51:~$ jupyter labextension list
JupyterLab v3.0.4
/home/g/.local/share/jupyter/labextensions
        jupyterlab-jupytext v1.3.0 enabled OK (python, jupytext)
        @jupyter-widgets/jupyterlab-manager v3.0.0 enabled OK (python, jupyterlab_widgets)

Other labextensions (built into JupyterLab)
   app dir: /home/g/.local/share/jupyter/lab

Contents of .jupyter/jupyter_notebook_config.json:

{
  "NotebookApp": {
    "nbserver_extensions": {
      "jupytext": true
    }
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 6
  • Comments: 28 (12 by maintainers)

Most upvoted comments

The issue is solved for me with jupyter_core==4.9.1

@sbrunk , I confirm that I am able to reproduce the issue and your resolution.

On Ubuntu 20.04, I have run

sudo apt-get install pip
pip install jupytext
pip install jupyter
export PATH=$PATH:~/.local/bin

With the above I do get the configuration files for Jupytext in ~/.local/etc/jupyter

$ tree ~/.local/etc/jupyter/
/home/marc/.local/etc/jupyter/
├── jupyter_notebook_config.d
│   ├── jupyterlab.json
│   └── jupytext.json
├── jupyter_server_config.d
│   ├── jupyterlab.json
│   ├── jupytext.json
│   └── nbclassic.json
└── nbconfig
    └── notebook.d
        └── jupytext.json

4 directories, 6 files

but as you said, they are not effective because that path is not listed in jupyter --paths:

$ jupyter --paths
config:
    /home/marc/.jupyter
    /usr/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /home/marc/.local/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /home/marc/.local/share/jupyter/runtime

The workaround cp -r $HOME/.local/etc/jupyter/* $HOME/.jupyter/ does work.

Another possibility seems to be

export JUPYTER_CONFIG_PATH="${HOME}/.local/etc/jupyter"

I think I’ll open an issue on the Jupyter project to see what they recommend (I’ll also ask if ${HOME}/.local/etc/jupyter is a standard config location, or not)

I just ran into this issue as well after installing jupytext along with jupyterlab outside of a virtual env via pip as a non-root Linux user (which implicitly sets the --user option on a pip install.

This results in the modern directory based config to be put into $HOME/.local/etc/jupyter, like this:

tree ~/.local/etc/jupyter 
.local/etc/jupyter
├── jupyter_notebook_config.d
│   ├── jupyterlab.json
│   ├── jupyter-server-proxy-notebookserverextension.json
│   └── jupytext.json
├── jupyter_server_config.d
│   ├── jupyterlab.json
│   ├── jupyter-server-proxy-jupyterserverextension.json
│   ├── jupytext.json
│   └── nbclassic.json

But jupyter only looks for config in $HOME/.jupyter and system paths, NOT in $HOME/.local/etc/jupyter (you can check with jupyter --paths). This is different in a conda env (and probably virtualenv) where jupyter also looks in /path-to-env/etc/jupyter.

So in my case the workaround was just a cp -r $HOME/.local/etc/jupyter/* $HOME/.jupyter/.

It occurred to me that perhaps I should be putting the above line in .jupyter/jupyter_lab_config.py since I am running jupyter lab This finally made something happen:

g@g-ThinkPad-P51:~$ jupyter lab
[W 2021-01-14 17:51:51.883 LabApp] 'contents_manager_class' 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-01-14 17:51:51.938 ServerApp] The 'contents_manager_class' trait of a ServerApp instance expected a subclass of 'jupyter_server.services.contents.manager.ContentsManager', not the JupytextContentsManager JupytextContentsManager.
[I 2021-01-14 17:51:51.959 ServerApp] The port 8888 is already in use, trying another port.
[I 2021-01-14 17:51:51.962 LabApp] JupyterLab extension loaded from /home/g/.local/lib/python3.8/site-packages/jupyterlab
[I 2021-01-14 17:51:51.962 LabApp] JupyterLab application directory is /home/g/.local/share/jupyter/lab
[I 2021-01-14 17:51:51.965 ServerApp] jupyterlab | extension was successfully loaded.
[I 2021-01-14 17:51:51.965 ServerApp] Serving notebooks from local directory: /home/g
[I 2021-01-14 17:51:51.965 ServerApp] Jupyter Server 1.2.1 is running at:
[I 2021-01-14 17:51:51.965 ServerApp] http://localhost:8889/lab?token=10bebb1d65dbf85bcdebf776e151ff0fb4ed425d9837229b
[I 2021-01-14 17:51:51.965 ServerApp]  or http://127.0.0.1:8889/lab?token=10bebb1d65dbf85bcdebf776e151ff0fb4ed425d9837229b
[I 2021-01-14 17:51:51.965 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 2021-01-14 17:51:52.003 ServerApp] 
    
    To access the server, open this file in a browser:
        file:///home/g/.local/share/jupyter/runtime/jpserver-105819-open.html
    Or copy and paste one of these URLs:
        http://localhost:8889/lab?token=10bebb1d65dbf85bcdebf776e151ff0fb4ed425d9837229b
     or http://127.0.0.1:8889/lab?token=10bebb1d65dbf85bcdebf776e151ff0fb4ed425d9837229b
[I 2021-01-14 17:51:55.656 LabApp] Build is up to date

Hi everyone, I wanted to let you know that the issue should be solved in jupyter_core==4.9.0.

At the moment a RC candidate for jupyter_core is available (thanks to @jasongrout)

pip install jupyter_core==4.9.0rc0

Could you please give it a try and confirm that it does solve the issue?

I will try but I have to find the time…

Well done @sbrunk! Thank you for your help in solving this long standing issue.

Next week I will make sure I can now reproduce the issue (I guess a simple pip install jupytext on a recent Ubuntu should do it?), and then I’ll add a mention of the fix (copy the config files at the right place) to the documentation.

I just ran into this issue as well after installing jupytext along with jupyterlab outside of a virtual env via pip as a non-root Linux user (which implicitly sets the --user option on a pip install. … So in my case the workaround was just a cp -r $HOME/.local/etc/jupyter/* $HOME/.jupyter/.

I think that you finally understood what happened. I do have $HOME/.local/etc/jupyter/ but I had not realized until now. Thanks for the message.

Hi @jarradh , thanks for reporting this issue. Could you please tell us what kind of icons you get for .md and .py files? (if you get a notebook icon then it means that Jupytext’s contents manager is working OK, if not indeed you have the same issue as the one reported here).

Also it is expected that you get the Jupytext sub menu in Jupyter Notebook only. In JupyterLab all that is available are the Jupyter Commands, under View / Activate Command Palette.

Note that you can compare what you get locally with the screenshot in the documentation, and also compare with Binder:lab

Arg this is becoming very technical… do you notice this?

'contents_manager_class' has moved from NotebookApp to ServerApp ... enpected a subclass of 'jupyter_server.services.contents.manager.ContentsManager'

This is something that is taken care of by the Jupytext server extension: https://github.com/mwouts/jupytext/blob/master/jupytext/__init__.py#L40-L42

Of course we could reproduce that in your config file - something like

from jupytext.contentsmanager import build_jupytext_contents_manager_class
from jupyter_server.services.contents.largefilemanager import LargeFileManager

c.NotebookApp.contents_manager_class = build_jupytext_contents_manager_class(LargeFileManager)

But I think that a better advice would be to get the server extension working. Would you mind to create a new environment / jupyter config from scratch? Personally I like very much conda/mamba for this, I’d create an environment.yml file with this content (at least):

name: jupytext-env
channels:
  - defaults
  - conda-forge
dependencies:
  - jupyterlab >=3
  - jupytext

and run

mamba env create -n environment.yml

(or conda env ... if you don’t have mamba)