emacs-jupyter / jupyter

An interface to communicate with Jupyter kernels.
GNU General Public License v3.0
912 stars 89 forks source link

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

Open sternj opened 10 months ago

sternj commented 10 months ago

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 commented 10 months ago

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

dangom commented 10 months ago

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

sternj commented 10 months ago

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 commented 10 months ago

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?

dangom commented 10 months ago

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.

TurbulenceChaos commented 10 months ago

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?

sternj commented 10 months ago

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.

zhenwu0728 commented 10 months ago

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.

nnicandro commented 8 months ago

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?

fakeGenuis commented 8 months ago

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)))
aelsayd commented 8 months ago

(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?

ed9w2in6 commented 8 months ago

maybe related to this? #478

dlukes commented 6 months ago

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 :)