Kotlin / kotlin-jupyter

Kotlin kernel for Jupyter/IPython
Apache License 2.0
1.09k stars 106 forks source link

The `nbconvert` failed to execute the `Kotlin` notebook #401

Closed KubaOfca closed 1 year ago

KubaOfca commented 1 year ago

Description

By running notebook with Kotlin kernel with this command:

conda run jupyter nbconvert --ExecutePreprocessor.timeout=-1 --ExecutePreprocessor.allow_errors=False --to notebook --execute --inplace my-new-project-Kotlin/notebooks/notebook.ipynb

I notice this error:

Traceback (most recent call last):
  File "/home/jakub/miniconda3/envs/my-new-project-Kotlin/bin/jupyter-nbconvert", line 6, in <module>
    from nbconvert.nbconvertapp import main
  File "/home/jakub/miniconda3/envs/my-new-project-Kotlin/lib/jvm/graalvm-189e927686-java17-22.3.0/languages/python/lib/python3.8/site-packages/nbconvert/__init__.py", line 6, in <module>
    from . import filters, postprocessors, preprocessors, writers
  File "/home/jakub/miniconda3/envs/my-new-project-Kotlin/lib/jvm/graalvm-189e927686-java17-22.3.0/languages/python/lib/python3.8/site-packages/nbconvert/filters/__init__.py", line 8, in <module>
    from .markdown import *
  File "/home/jakub/miniconda3/envs/my-new-project-Kotlin/lib/jvm/graalvm-189e927686-java17-22.3.0/languages/python/lib/python3.8/site-packages/nbconvert/filters/markdown.py", line 13, in <module>
    from .markdown_mistune import markdown2html_mistune
  File "/home/jakub/miniconda3/envs/my-new-project-Kotlin/lib/jvm/graalvm-189e927686-java17-22.3.0/languages/python/lib/python3.8/site-packages/nbconvert/filters/markdown_mistune.py", line 16, in <module>
    import bs4
  File "/home/jakub/miniconda3/envs/my-new-project-Kotlin/lib/jvm/graalvm-189e927686-java17-22.3.0/languages/python/lib/python3.8/site-packages/bs4/__init__.py", line 37, in <module>
    from .builder import (
  File "/home/jakub/miniconda3/envs/my-new-project-Kotlin/lib/jvm/graalvm-189e927686-java17-22.3.0/languages/python/lib/python3.8/site-packages/bs4/builder/__init__.py", line 627, in <module>
    from . import _lxml
  File "/home/jakub/miniconda3/envs/my-new-project-Kotlin/lib/python3.8/site-packages/bs4/builder/_lxml.py", line 193
    if len(markup) > 0 and markup[0] == u'\N{BYTE ORDER MARK}':
                                        ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-18: unknown Unicode character name
ERROR conda.cli.main_run:execute(47): `conda run jupyter nbconvert --ExecutePreprocessor.timeout=-1 --ExecutePreprocessor.allow_errors=False --to notebook --execute --inplace my-new-project-Kotlin/notebooks/notebook.ipynb` failed. (See above for error)

As a result, notebook isn't executed.

Apart from executing notebook by nbconvert, executing it inside jupyter lab cell works fine without errors.

Expected behavior

Notebook is executed with nbconvert

Environment

Conda environment dependencies:

dependencies:
  - jupyterlab>=3.5.0
  - kotlin-jupyter-kernel>=0.11.0.15
  - openjdk>=17.0.5.8
KubaOfca commented 1 year ago

Changing the dependency version to:

  - jupyterlab>=3.5.0
  - kotlin-jupyter-kernel>=0.11.0.255
  - openjdk>=17.0.3

solved the problem.

ileasile commented 1 year ago

This trace looks like an environment problem, see, it fails on from . import _lxml. I believe it didn't even started to do something with the notebook at this point of time. But I'm glad that this problem got somehow fixed for you!