jupyterlab / jupyterlab_pygments

Pygments theme making use of JupyterLab CSS variables
BSD 3-Clause "New" or "Revised" License
40 stars 30 forks source link

AssertionError: wrong color format 'var(--jp-mirror-editor-variable-color)' while opening jupyter notebook #10

Open s-mx opened 2 years ago

s-mx commented 2 years ago

Description

Hi. I tried running jupyter notebook recently and faced with the following issue. I run local jupyter server, try to open any notebook from filesystem and I get 500 : Internal Server Error.

Here are logs from jupyter server.

[E 22:47:46.040 NotebookApp] Uncaught exception GET /notebooks/sem_tasks/05_data_files2/TOBD_sem_05_data_files2_v2_blank.ipynb (127.0.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/notebooks/sem_tasks/05_data_files2/TOBD_sem_05_data_files2_v2_blank.ipynb', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/dist-packages/tornado/web.py", line 1704, in _execute
        result = await result
      File "/usr/local/lib/python3.8/dist-packages/tornado/gen.py", line 775, in run
        yielded = self.gen.send(value)
      File "/usr/local/lib/python3.8/dist-packages/notebook/notebook/handlers.py", line 95, in get
        self.write(self.render_template('notebook.html',
      File "/usr/local/lib/python3.8/dist-packages/notebook/base/handlers.py", line 516, in render_template
        return template.render(**ns)
      File "/home/sabyanin/.local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
        self.environment.handle_exception()
      File "/home/sabyanin/.local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
        reraise(*rewrite_traceback_stack(source=source))
      File "/home/sabyanin/.local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
        raise value.with_traceback(tb)
      File "/usr/local/lib/python3.8/dist-packages/notebook/templates/notebook.html", line 1, in top-level template code
        {% extends "page.html" %}
      File "/usr/local/lib/python3.8/dist-packages/notebook/templates/page.html", line 154, in top-level template code
        {% block header %}
      File "/usr/local/lib/python3.8/dist-packages/notebook/templates/notebook.html", line 115, in block "header"
        {% for exporter in get_frontend_exporters() %}
      File "/usr/local/lib/python3.8/dist-packages/notebook/notebook/handlers.py", line 23, in get_frontend_exporters
        from nbconvert.exporters.base import get_export_names, get_exporter
      File "/usr/local/lib/python3.8/dist-packages/nbconvert/__init__.py", line 4, in <module>
        from .exporters import *
      File "/usr/local/lib/python3.8/dist-packages/nbconvert/exporters/__init__.py", line 4, in <module>
        from .slides import SlidesExporter
      File "/usr/local/lib/python3.8/dist-packages/nbconvert/exporters/slides.py", line 12, in <module>
        from ..preprocessors.base import Preprocessor
      File "/usr/local/lib/python3.8/dist-packages/nbconvert/preprocessors/__init__.py", line 7, in <module>
        from .csshtmlheader import CSSHTMLHeaderPreprocessor
      File "/usr/local/lib/python3.8/dist-packages/nbconvert/preprocessors/csshtmlheader.py", line 14, in <module>
        from jupyterlab_pygments import JupyterStyle
      File "/usr/local/lib/python3.8/dist-packages/jupyterlab_pygments/__init__.py", line 4, in <module>
        from .style import JupyterStyle
      File "/usr/local/lib/python3.8/dist-packages/jupyterlab_pygments/style.py", line 10, in <module>
        class JupyterStyle(Style):
      File "/usr/lib/python3/dist-packages/pygments/style.py", line 101, in __new__
        ndef[0] = colorformat(styledef)
      File "/usr/lib/python3/dist-packages/pygments/style.py", line 58, in colorformat
        assert False, "wrong color format %r" % text
    AssertionError: wrong color format 'var(--jp-mirror-editor-variable-color)'
[E 22:47:46.045 NotebookApp] {
      "Host": "localhost:8888",
      "Connection": "keep-alive",
      "Sec-Ch-Ua": "\"Chromium\";v=\"94\", \"Google Chrome\";v=\"94\", \";Not A Brand\";v=\"99\"",
      "Sec-Ch-Ua-Mobile": "?0",
      "Sec-Ch-Ua-Platform": "\"Linux\"",
      "Upgrade-Insecure-Requests": "1",
      "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
      "Sec-Fetch-Site": "same-origin",
      "Sec-Fetch-Mode": "navigate",
      "Sec-Fetch-User": "?1",
      "Sec-Fetch-Dest": "document",
      "Referer": "http://localhost:8888/tree/sem_tasks/05_data_files2",
      "Accept-Encoding": "gzip, deflate, br",
      "Accept-Language": "en-US,en;q=0.9,ru;q=0.8",
      "Cookie": "_xsrf=2|471c0411|ef46fbdadc5c7e7d8a5a58823e4c6c33|1639510655; username-localhost-8888=\"2|1:0|10:1639511260|23:username-localhost-8888|44:ODhiY2Y0ZWIyYzQ4NGJjZTlmNmM3MmY5MzA4ODg2ZWQ=|d4ae11da3ee3adf2eb98e1c8e69ec53333c5aaaaf3ccd58427bd5bdcda54fbc4\""
    }
[E 22:47:46.045 NotebookApp] 500 GET /notebooks/sem_tasks/05_data_files2/TOBD_sem_05_data_files2_v2_blank.ipynb (127.0.0.1) 69.940000ms referer=http://localhost:8888/tree/sem_tasks/05_data_files2

Reproducer

I installed jupyter with the following steps.

sudo pip3 install virtualenv
virtualenv env
source ./env/bin/activate
pip3 install jupyter

Context

When faced issue for first time tried to google it. Found a recommendation to update pygments to >=2.4.1. Did pip3 install --upgrade pygments. Didn't help. Also tried to update nbconvert. Didn't help as well. Here is the list of packages in pip3:

Package              Version
-------------------- ---------
alembic              1.7.5
argon2-cffi          21.3.0
argon2-cffi-bindings 21.2.0
async-generator      1.10
attrs                21.2.0
backcall             0.2.0
bleach               4.1.0
certifi              2021.10.8
certipy              0.1.3
cffi                 1.15.0
charset-normalizer   2.0.9
cryptography         36.0.0
debugpy              1.5.1
decorator            5.1.0
defusedxml           0.7.1
entrypoints          0.3
greenlet             1.1.2
idna                 3.3
importlib-metadata   4.8.2
importlib-resources  5.4.0
ipykernel            6.6.0
ipython              7.30.1
ipython-genutils     0.2.0
ipywidgets           7.6.5
jedi                 0.18.1
Jinja2               3.0.3
jsonschema           4.2.1
jupyter              1.0.0
jupyter-client       7.1.0
jupyter-console      6.4.0
jupyter-core         4.9.1
jupyter-telemetry    0.1.0
jupyterhub           2.0.0
jupyterlab-pygments  0.1.2
jupyterlab-widgets   1.0.2
Mako                 1.1.6
MarkupSafe           2.0.1
matplotlib-inline    0.1.3
mistune              0.8.4
nbclient             0.5.9
nbconvert            6.3.0
nbformat             5.1.3
nest-asyncio         1.5.4
notebook             6.4.6
oauthlib             3.1.1
packaging            21.3
pamela               1.0.0
pandocfilters        1.5.0
parso                0.8.3
pexpect              4.8.0
pickleshare          0.7.5
pip                  21.3.1
prometheus-client    0.12.0
prompt-toolkit       3.0.24
ptyprocess           0.7.0
pycparser            2.21
Pygments             2.10.0
pyOpenSSL            21.0.0
pyparsing            3.0.6
pyrsistent           0.18.0
python-dateutil      2.8.2
python-json-logger   2.0.2
pyzmq                22.3.0
qtconsole            5.2.2
QtPy                 1.11.3
requests             2.26.0
ruamel.yaml          0.17.17
ruamel.yaml.clib     0.2.6
Send2Trash           1.8.0
setuptools           58.3.0
six                  1.16.0
SQLAlchemy           1.4.28
terminado            0.12.1
testpath             0.5.0
tornado              6.1
traitlets            5.1.1
urllib3              1.26.7
wcwidth              0.2.5
webencodings         0.5.1
wheel                0.37.0
widgetsnbextension   3.5.2
zipp                 3.6.0
Troubleshoot Output
$PATH:
    /home/sabyanin/university/finashka/env/bin
    /home/sabyanin/bin/google-cloud-sdk-299.0.0-linux-x86_64/google-cloud-sdk/bin
    /home/sabyanin/.local/bin
    /home/sabyanin/bin
    /usr/local/sbin
    /usr/local/bin
    /usr/sbin
    /usr/bin
    /sbin
    /bin
    /usr/games
    /usr/local/games
    /snap/bin
    /usr/local/go/bin
    /home/sabyanin/bin
    /usr/local/go/bin

sys.path:
    /usr/local/bin
    /usr/lib/python38.zip
    /usr/lib/python3.8
    /usr/lib/python3.8/lib-dynload
    /home/sabyanin/.local/lib/python3.8/site-packages
    /usr/local/lib/python3.8/dist-packages
    /usr/lib/python3/dist-packages

sys.executable:
    /usr/bin/python3

sys.version:
    3.8.10 (default, Sep 28 2021, 16:10:42) 
    [GCC 9.3.0]

platform.platform():
    Linux-5.4.0-64-generic-x86_64-with-glibc2.29

which -a jupyter:
    /home/sabyanin/university/finashka/env/bin/jupyter
    /usr/local/bin/jupyter

pip list:
    Package                           Version             
    --------------------------------- --------------------
    aioquic                           0.9.6               
    apturl                            0.5.2               
    argon2-cffi                       21.3.0              
    argon2-cffi-bindings              21.2.0              
    attrs                             21.2.0              
    backcall                          0.1.0               
    backports.entry-points-selectable 1.1.1               
    bcrypt                            3.1.7               
    bleach                            4.1.0               
    blinker                           1.4                 
    bottle                            0.12.19             
    Brlapi                            0.7.0               
    certifi                           2018.1.18           
    cffi                              1.15.0              
    chardet                           3.0.4               
    chrome-gnome-shell                0.0.0               
    cliapp                            1.20180812.1        
    click                             7.1.2               
    cmdtest                           0.32+git            
    colorama                          0.4.3               
    command-not-found                 0.3                 
    conan                             1.33.1              
    cryptography                      2.8                 
    cupshelpers                       1.0                 
    cycler                            0.10.0              
    dbus-python                       1.2.16              
    debugpy                           1.5.1               
    decorator                         4.4.2               
    defer                             1.0.6               
    defusedxml                        0.7.1               
    deprecation                       2.0.7               
    devscripts                        2.20.2ubuntu2       
    distlib                           0.3.4               
    distro                            1.4.0               
    distro-info                       0.23ubuntu1         
    docker                            4.1.0               
    docopt                            0.6.2               
    entrypoints                       0.3                 
    fasteners                         0.16                
    filelock                          3.4.0               
    Flask                             0.12.2              
    future                            0.18.2              
    Glances                           3.1.3               
    gpg                               1.13.1-unknown      
    greenlet                          0.4.15              
    grip                              4.5.2               
    gspread                           0.6.2               
    Guake                             3.6.3               
    gunicorn                          19.4.5              
    httplib2                          0.14.0              
    idna                              2.6                 
    importlib-resources               5.4.0               
    influxdb                          5.2.0               
    iotop                             0.6                 
    ipykernel                         6.6.0               
    ipython                           7.30.1              
    ipython-genutils                  0.2.0               
    ipywidgets                        7.6.5               
    itsdangerous                      1.1.0               
    jedi                              0.18.1              
    Jinja2                            2.11.2              
    jsonschema                        4.2.1               
    jupyter                           1.0.0               
    jupyter-client                    7.1.0               
    jupyter-console                   6.4.0               
    jupyter-core                      4.9.1               
    jupyterlab-pygments               0.1.2               
    jupyterlab-widgets                1.0.2               
    keyring                           18.0.1              
    kiwisolver                        1.0.1               
    language-selector                 0.1                 
    launchpadlib                      1.10.13             
    lazr.restfulclient                0.14.2              
    lazr.uri                          1.0.3               
    libvirt-python                    6.1.0               
    louis                             3.12.0              
    macaroonbakery                    1.3.1               
    Markdown                          3.1.1               
    MarkupSafe                        1.1.1               
    matplotlib                        3.1.2               
    matplotlib-inline                 0.1.3               
    mistune                           0.8.4               
    msgpack                           0.6.2               
    nbclient                          0.5.9               
    nbconvert                         6.3.0               
    nbformat                          5.1.3               
    nest-asyncio                      1.5.4               
    netifaces                         0.10.4              
    node-semver                       0.6.1               
    notebook                          6.4.6               
    numpy                             1.17.4              
    oauth2client                      4.1.2               
    oauthlib                          3.1.0               
    olefile                           0.46                
    packaging                         20.3                
    pandocfilters                     1.5.0               
    paramiko                          2.6.0               
    parso                             0.8.3               
    patch-ng                          1.17.4              
    path-and-address                  2.0.1               
    pbr                               5.4.5               
    pexpect                           4.6.0               
    pickleshare                       0.7.5               
    Pillow                            7.0.0               
    pip                               20.0.2              
    platformdirs                      2.4.0               
    pluginbase                        1.0.0               
    ply                               3.11                
    prometheus-client                 0.12.0              
    prompt-toolkit                    2.0.10              
    protobuf                          3.6.1               
    psutil                            5.5.1               
    ptyprocess                        0.7.0               
    pyasn1                            0.4.8               
    pyasn1-modules                    0.2.8               
    pycairo                           1.16.2              
    pycparser                         2.21                
    pycryptodomex                     3.6.1               
    pycups                            1.9.73              
    Pygments                          2.3.1               
    PyGObject                         3.36.0              
    PyJWT                             1.7.1               
    pylsqpack                         0.3.10              
    pymacaroons                       0.13.0              
    PyNaCl                            1.3.0               
    pynvim                            0.4.1               
    pyparsing                         2.4.6               
    pyRFC3339                         1.1                 
    pyrsistent                        0.18.0              
    pysmi                             0.3.2               
    pysnmp                            4.4.6               
    pystache                          0.5.4               
    python-apt                        2.0.0+ubuntu0.20.4.6
    python-dateutil                   2.7.3               
    python-debian                     0.1.36ubuntu1       
    python-gitlab                     1.5.1               
    python-magic                      0.4.16              
    pytz                              2017.3              
    pyxdg                             0.26                
    PyYAML                            3.12                
    pyzmq                             22.3.0              
    qtconsole                         5.2.2               
    QtPy                              1.11.3              
    redis                             2.10.6              
    reportlab                         3.5.34              
    requests                          2.18.4              
    requests-unixsocket               0.2.0               
    rsa                               4.6                 
    SecretStorage                     2.3.1               
    Send2Trash                        1.8.0               
    setuptools                        45.2.0              
    simplejson                        3.16.0              
    six                               1.14.0              
    ssh-import-id                     5.10                
    systemd-python                    234                 
    terminado                         0.12.1              
    testpath                          0.5.0               
    tornado                           6.1                 
    tqdm                              4.57.0              
    traitlets                         5.1.1               
    ttystatus                         0.38                
    ubuntu-advantage-tools            27.4                
    ubuntu-drivers-common             0.0.0               
    ufw                               0.36                
    unattended-upgrades               0.1                 
    unidiff                           0.5.5               
    urllib3                           1.22                
    virtualenv                        20.10.0             
    wadllib                           1.3.3               
    wcwidth                           0.1.8               
    webencodings                      0.5.1               
    websocket-client                  0.53.0              
    Werkzeug                          0.14.1              
    wheel                             0.34.2              
    widgetsnbextension                3.5.2               
    xkit                              0.0.0               
    zipp                              3.6.0
welcome[bot] commented 2 years ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada: