tkf/emacs-ipython-notebook

! very strange saving issue !

shelper opened this issue · 8 comments

I am using MELPA package that was updated on 2015-01-11, I have a big cell with many lines of code,
and I want to save the notebook by C-x C-s, what happened is i got saving error

ein: [error] Content list call http://127.0.0.1:8888/api/contents/groupbysto2.ipynb failed with status nil.
ein: [info] Failed to save notebook!

i found that one cell in EIN cannot have more than certain number of lines or characters, e.g, even i put 100 lines of import os.path, i cannot save the notebook.

I am on windows 7, emacs 24.5, ipython 4.0 (jupyter) for python 3.4.3

Does saving work when you use the browser interface? Also, what is the terminal output for ipython when saving from ein fails?

saving works in both browser and emacs, the problem is the emacs gives error, but the file is saved...
no warning/error output in the terminal

but things become more complicated when today i tried again to save-buffer in emacs, i have the error mesage like below

ein: [info] Writing notebook Untitled.ipynb as nbformat 4.
ein:notebook-save-notebook: Wrong type argument: number-or-marker-p, nil

i tried to enable the debug-on-error, but it just could not enter the debug mode, then I tried to start a new notebook but failed by getting the error below:

Debugger entered--Lisp error: (void-variable default-kernel)
  #[(&rest ignore) "\303\304�\305H  >\204� \306\307\310\311#\210�\312H\n\"!\207" [ein:%notebooklist% cl-struct-ein:$notebooklist-tags default-kernel call-interactively ein:notebooklist-new-notebook 0 error "%s accessing a non-%s" ein:$notebooklist-url-or-port ein:$notebooklist 1] 6]((link :args nil :value "New Notebook" :notify #[(&rest ignore) "\303\304�\305H  >\204� \306\307\310\311#\210�\312H\n\"!\207" [ein:%notebooklist% cl-struct-ein:$notebooklist-tags default-kernel call-interactively ein:notebooklist-new-notebook 0 error "%s accessing a non-%s" ein:$notebooklist-url-or-port ein:$notebooklist 1] 6] :button-overlay #<overlay from 39 to 53 in *ein:notebooklist 8888*> :from #<marker (moves after insertion) at 39 in *ein:notebooklist 8888*> :to #<marker at 53 in *ein:notebooklist 8888*>) (link :args nil :value "New Notebook" :notify #[(&rest ignore) "\303\304�\305H >\204� \306\307\310\311#\210�\312H\n\"!\207" [ein:%notebooklist% cl-struct-ein:$notebooklist-tags default-kernel call-interactively ein:notebooklist-new-notebook 0 error "%s accessing a non-%s" ein:$notebooklist-url-or-port ein:$notebooklist 1] 6] :button-overlay #<overlay from 39 to 53 in *ein:notebooklist 8888*> :from #<marker (moves after insertion) at 39 in *ein:notebooklist 8888*> :to #<marker at 53 in *ein:notebooklist 8888*>) nil)
  widget-apply((link :args nil :value "New Notebook" :notify #[(&rest ignore) "\303\304�\305H   >\204� \306\307\310\311#\210�\312H\n\"!\207" [ein:%notebooklist% cl-struct-ein:$notebooklist-tags default-kernel call-interactively ein:notebooklist-new-notebook 0 error "%s accessing a non-%s" ein:$notebooklist-url-or-port ein:$notebooklist 1] 6] :button-overlay #<overlay from 39 to 53 in *ein:notebooklist 8888*> :from #<marker (moves after insertion) at 39 in *ein:notebooklist 8888*> :to #<marker at 53 in *ein:notebooklist 8888*>) :notify (link :args nil :value "New Notebook" :notify #[(&rest ignore) "\303\304�\305H >\204� \306\307\310\311#\210�\312H\n\"!\207" [ein:%notebooklist% cl-struct-ein:$notebooklist-tags default-kernel call-interactively ein:notebooklist-new-notebook 0 error "%s accessing a non-%s" ein:$notebooklist-url-or-port ein:$notebooklist 1] 6] :button-overlay #<overlay from 39 to 53 in *ein:notebooklist 8888*> :from #<marker (moves after insertion) at 39 in *ein:notebooklist 8888*> :to #<marker at 53 in *ein:notebooklist 8888*>) nil)
  widget-item-action((link :args nil :value "New Notebook" :notify #[(&rest ignore) "\303\304�\305H >\204� \306\307\310\311#\210�\312H\n\"!\207" [ein:%notebooklist% cl-struct-ein:$notebooklist-tags default-kernel call-interactively ein:notebooklist-new-notebook 0 error "%s accessing a non-%s" ein:$notebooklist-url-or-port ein:$notebooklist 1] 6] :button-overlay #<overlay from 39 to 53 in *ein:notebooklist 8888*> :from #<marker (moves after insertion) at 39 in *ein:notebooklist 8888*> :to #<marker at 53 in *ein:notebooklist 8888*>) nil)
  widget-apply((link :args nil :value "New Notebook" :notify #[(&rest ignore) "\303\304�\305H   >\204� \306\307\310\311#\210�\312H\n\"!\207" [ein:%notebooklist% cl-struct-ein:$notebooklist-tags default-kernel call-interactively ein:notebooklist-new-notebook 0 error "%s accessing a non-%s" ein:$notebooklist-url-or-port ein:$notebooklist 1] 6] :button-overlay #<overlay from 39 to 53 in *ein:notebooklist 8888*> :from #<marker (moves after insertion) at 39 in *ein:notebooklist 8888*> :to #<marker at 53 in *ein:notebooklist 8888*>) :action nil)
  widget-apply-action((link :args nil :value "New Notebook" :notify #[(&rest ignore) "\303\304�\305H    >\204� \306\307\310\311#\210�\312H\n\"!\207" [ein:%notebooklist% cl-struct-ein:$notebooklist-tags default-kernel call-interactively ein:notebooklist-new-notebook 0 error "%s accessing a non-%s" ein:$notebooklist-url-or-port ein:$notebooklist 1] 6] :button-overlay #<overlay from 39 to 53 in *ein:notebooklist 8888*> :from #<marker (moves after insertion) at 39 in *ein:notebooklist 8888*> :to #<marker at 53 in *ein:notebooklist 8888*>) nil)
  widget-button-press(39)
  evil-ret-gen(nil nil)
  evil-ret(nil)
  call-interactively(evil-ret nil nil)
  command-execute(evil-ret)

I have no idea what happened....:(

Okay I just tried to reproduce this by creating a code cell with >400 lines of Python in it. EIN did not report to me the error that you saw, so.... Could you attach a copy of the notebook that is generating the error?

Also not sure what is up with the notebook creating error, though it is probably a separate issue. I suggest calling ein:byte-compile-ein and restarting Emacs. Also, before enabling debug-on-error you need to call ein:dev-start-debug else behavior gets wonky.

I have no idea what happened, now, the save function worked!

but still cannot create new notebook, have the error message when i enable ein debug:

Debugger entered--Lisp error: (void-variable default-kernel)
  #[... "\303\304�\305H >\204�
  widget-apply((link :args nil :value "New Notebook" :notify #[... "\303\304�\305H  >\204�
  widget-item-action((link :args nil :value "New Notebook" :notify #[... "\303\304�\305H    >\204�
  widget-apply((link :args nil :value "New Notebook" :notify #[... "\303\304�\305H  >\204�
  widget-apply-action((link :args nil :value "New Notebook" :notify #[... "\303\304�\305H   >\204�
  widget-button-press(39)
  evil-ret-gen(nil nil)
  evil-ret(nil)
  call-interactively(evil-ret nil nil)
  command-execute(evil-ret)

Could you try the following:

What are the results of calling (ein:list-available-kernels 8888) - I assume jupyter is running on port 8888. If not then you will need to adjust accordingly.

Also, what is returned when you access http://127.0.0.1:8888/api/kernelspecs (again adjusting the port to match your actual configuration).

well, the output of (ein:list-available-kernels 8888) is python3, and then i found after i click
Create New Notebooks Using Kernel: (*) python3 in the below list, i can then create new notebook.
I don't know if it can be considered as a bug, or this is what i should do before creating new notebooks...

IPython 3 Notebook list

 | [Home] |

[New Notebook] [Reload List] [Open In Browser]

Create New Notebooks Using Kernel: 
(*) python3

 [Dir] : calibration
 [Dir] : ELC_pytools
 [Dir] : exceptions
 [Dir] : Group1
 [Dir] : Group2
 [Dir] : Group3
 [Open] [Delete] : Untitled.ipynb
 [Open] [Delete] : Untitled1.ipynb
 [Open] [Stop] [Delete] : Untitled2.ipynb

The curse of async strikes again, I think. Querying jupytyer for the list of kernelspecs is done asynchronously just before rendering the notebooklist buffer. Apparently on your machine your emacs is really fast or jupyter is really slow, so the query is not complete by the time the buffer renders, resulting in default-kernel being nil, which mucks up everything when you try to create a new notebook.

Making the query synchronous is the easiest solution, but it will slow down the call to notebooklist-open so I'd like to think it over and make sure it is the right solution.

I found it's caused by permission problem, you can fix it by chown and chgrp command in linux.