luk400 / vim-jukit

Jupyter-Notebook inspired Neovim/Vim Plugin
MIT License
587 stars 23 forks source link

Error when opening a notebook with spaces #86

Open sulan opened 1 year ago

sulan commented 1 year ago

Hi,

When opening a notebook with spaces in the filename, I get the following error:

"file with spaces.ipynb" 60L, 1359B written
Error detected while processing function jukit#convert#notebook_convert[5]..<SNR>123_convert_to_script[12]..provider#python3#Call:
line   18:
Error invoking 'python_execute' on channel 5 (python3-script-host):
Traceback (most recent call last):
  File "<string>", line 6, in <module>
  File "/home/sulan/.local/share/nvim/site/pack/packer/start/vim-jukit/helpers/ipynb_convert/convert.py", line 123, in convert
    language, nb = get_nb_and_language(nb, lang)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sulan/.local/share/nvim/site/pack/packer/start/vim-jukit/helpers/ipynb_convert/util.py", line 11, in get_nb_and_language
    assert nb["nbformat"] > 3, (
           ~~^^^^^^^^^^^^
KeyError: 'nbformat'

It seems to come from nvim reporting the filename with \s in it, after which the python code (in load_json in utils.py) tries to load the wrong filename, and returns an empty dict.

Versions

datacubeR commented 1 year ago

I can confirm this weird behavior, even though I think it is never a great practice to have space in file names, this issue raises if the space is in any part of the path, even in previous folders that are not part of the relative path.... Fixed it eliminating spaces...

sahinakkaya commented 1 year ago

94 is also same issue. Keeping it open to prevent possible duplicate issues in the future.