jupyter icon indicating copy to clipboard operation
jupyter copied to clipboard

no `org-babel-execute-function` after upgrade

Open sternj opened this issue 2 years ago • 14 comments

Hi all, I just did a doom upgrade and I've stopped being able to use jupyter-python in org mode. The error that I get is

org-babel-execute-src-block: No org-babel-execute function for jupyter-python! 

The salient block in config.el is

(after! org
        (add-hook 'org-babel-after-execute-hook 'org-redisplay-inline-images)
        (org-babel-do-load-languages
         'org-babel-load-languages
         '((emacs-lisp . t)
           (julia . t)
           (python . t)
           (jupyter . t)))

       ;; (org-babel-jupyter-override-src-block "python")
        )

and I have org installed with (org +roam2 +pretty +jupyter) and Python installed with (python +pyenv +lsp +pyright)

I am getting some errors that may or may not be relevant at initialization:

Loading /Users/sam/.emacs.d/.local/cache/recentf...done
Waiting for git... [2 times]
Undo-Fu-Session can not recover undo data: Invalid read syntax: "#", 3, 160
Error in post-command-hook (org-appear--post-cmd): (wrong-type-argument number-or-marker-p nil)
Error in pre-command-hook (org-appear--pre-cmd): (wrong-type-argument number-or-marker-p nil)

When I describe-variable on org-babel-load-languages, I get

Its value is ((jupyter . t) (jupyter-python . t) (emacs-lisp . t)) Original value was ((emacs-lisp . t))

Any idea what's up?

sternj avatar Aug 16 '23 23:08 sternj

Worth noting that I reinstalled Emacs and removed .config/emacs and .config/doom but that didn't help and there still seem to be things cached from my last installation

sternj avatar Aug 16 '23 23:08 sternj

Org 9.7 broke a lot of things, I would suspect this is not necessarily related to emacs-jupyter. See also https://github.com/org-roam/org-roam/issues/2361

dangom avatar Aug 17 '23 15:08 dangom

Ah, thank you! I think it might be a good idea to put up a tracking issue on this repo so the next person looking knows to pin org at the older version for now

sternj avatar Aug 17 '23 15:08 sternj

Well, I'm back on 9.6.7 and the problem persists, I'm pinned with (package! org :pin "ca873f7") in packages.el and followed the instructions on the linked issue.org-babel-load-languages is still not updating-- am I updating it in the canonical way at the canonical location?

sternj avatar Aug 17 '23 16:08 sternj

Not sure, but the point is it's hard to assume this has anything to do with this repository when the issue seems to be related to your config and doom. Nothing changed in this repo that broke things that were previously working. In other words, you'd probably get better help opening an issue at the doom repo instead.

dangom avatar Aug 17 '23 19:08 dangom

Well, I'm back on 9.6.7 and the problem persists, I'm pinned with (package! org :pin "ca873f7") in packages.el and followed the instructions on the linked issue.org-babel-load-languages is still not updating-- am I updating it in the canonical way at the canonical location?

I pinned jupyter package with (package! jupyter :pin "16cbda79167b4e2f2c6b61b218658f0f660d97f9") in packages.el file and it works well in org mode 9.7. BTW, can you use jupyter widgets in org mode?

TurbulenceChaos avatar Aug 18 '23 07:08 TurbulenceChaos

Confirmed that this is a working fix-- perhaps it is something in this repo, then. As for widgets, I must confess to not knowing what they are-- I just use Jupyter for making graphs in all honesty.

sternj avatar Aug 18 '23 15:08 sternj

Having the same issue. Below is the error message.

~/.config/emacs/.local/straight/build-29.1/jupyter/jupyter-org-extensions.el:
    Warning: ‘buffer-substring’ is an obsolete generalized variable.

Also, reopening the org file solves the issue.

zhenwu0728 avatar Aug 19 '23 02:08 zhenwu0728

This may be due to 2f14f2e2531fc4ebfde5c3b5ae60c1d9c7a2b26b which causes the definition of the Jupyter based execute functions to be delayed until an Org file is opened. If your call to org-babel-do-load-languages happens after you have already opened your Org file, the execute functions may not be defined.

Does evaluating M-: (org-babel-jupyter-aliases-from-kernelspecs) resolve the issue or reopening the file?

nnicandro avatar Oct 16 '23 03:10 nnicandro

Run following and reopening .org file seems work

(advice-remove 'org-babel-do-load-languages #'ignore)

(org-babel-do-load-languages
 'org-babel-load-languages
 '((emacs-lisp . t)
   (julia . t)
   (python . t)
   (jupyter . t)))

fakeGenuis avatar Oct 16 '23 08:10 fakeGenuis

(org-babel-jupyter-aliases-from-kernelspecs)

I have reproduced the problem on doom emacs and can confirm that this does indeed fix it . Is there a better workaround?

aelsayd avatar Oct 24 '23 04:10 aelsayd

maybe related to this? #478

ed9w2in6 avatar Nov 06 '23 11:11 ed9w2in6

Is there a better workaround?

See this comment for how to set it up so you don't have to run it manually each time, if that qualifies as better :)

dlukes avatar Dec 31 '23 00:12 dlukes

Experiencing the same issue. Using this package with a kernel server. Neither https://github.com/emacs-jupyter/jupyter/issues/489#issuecomment-1763980051 nor https://github.com/emacs-jupyter/jupyter/issues/489#issuecomment-1763653191 seem to help. The current workaround that I found was running a code block of type jupyter, after which the various language aliases get loaded. However, this unnecessarily creates a kernel on the server before I can actually use the package.

jupyter 20240716.2028 from melpa (org-version) "9.6.10" Emacs 29.3

Current workaround that I found is to run

(let ((default-directory "/jpy:localhost#8888:"))
  (org-babel-jupyter-aliases-from-kernelspecs)
  )

in the scratch buffer, Assuming /jpy:localhost#8888: is the address of the kernel server, or adding a block such as the following at the beginning of your org file:

#+begin_src emacs-lisp
  (let ((default-directory "/jpy:localhost#8888:"))
  (org-babel-jupyter-aliases-from-kernelspecs)
  )
#+end_src

sprig avatar Jul 23 '24 03:07 sprig