0

I issue

emacs -Q yes.org

where yes.org is

(org-babel-do-load-languages 'org-babel-load-languages '((python . t)))

#+begin_src python :results output
print(2)
#+end_src

I first evaluate the loading Python to babel expression with C-x C-e, and then go to the line of "print" and

  • press C-c C-c, I get
org-ctrl-c-ctrl-c: ‘C-c C-c’ can do nothing useful here
  • do M-x org-babel-execute-src-block, I get
funcall-interactively: Wrong type argument: consp, nil

To investigate latter more, I do M-: (setq debug-on-error t) and the *Backtrace* then reads:

Debugger entered--Lisp error: (wrong-type-argument consp nil)
  org-babel-execute-src-block()
  funcall-interactively(org-babel-execute-src-block)
  command-execute(org-babel-execute-src-block record)
  execute-extended-command(nil "org-babel-execute-src-block" "org-babel-execute-sr")
  funcall-interactively(execute-extended-command nil "org-babel-execute-src-block" "org-babel-execute-sr")
  command-execute(execute-extended-command)

which I don't understand. What's more, I get the exact same error even if I don't call the org-babel-do-load-languages function in the first line. What can I do to make the code block execute and put results?

"emacs --version" says "GNU Emacs 28.1", on Windows 10.


So i tried to manually call org-babel-execute-src-block ("C-x C-e"d this in the "yes.org"s buffer):

(org-babel-execute-src-block nil '("python" "print(2)" nil nil nil nil nil))

and the *Messages* reads

Can’t guess python-indent-offset, using defaults: 4
org-babel-insert-result: Wrong type argument: markerp, nil

So this time it looks like it did evalute the code, but had a hard time inserting it and errored out. The traceback is

Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
  org-babel-insert-result("None" nil ("python" "print(2)" ((:colname-names) (:rowname-names) (:result-params) (:result-type . value) (:results . "") (:exports . "")) nil nil nil nil) nil "python")
  org-babel-execute-src-block(nil ("python" "print(2)" nil nil nil nil nil))
  eval-expression((org-babel-execute-src-block nil '("python" "print(2)" nil nil nil nil nil)) nil nil 127)
  funcall-interactively(eval-expression (org-babel-execute-src-block nil '("python" "print(2)" nil nil nil nil nil)) nil nil 127)
  command-execute(eval-expression)

which I again don't know what it tells...

4
  • I have no problems doing what you describe above on Linux: it all works as it should. Presumably it's a Windows thing in general or it may be something peculiar to your setup, but I can't help with that.
    – NickD
    Commented Mar 18, 2023 at 1:13
  • What is the value of the org-babel-load-languages? Run M-x describe-variable.
    – Arktik
    Commented Mar 18, 2023 at 19:02
  • hi @Arktik, it says "Its value is ((python . t)) Original value was ((emacs-lisp . t))".
    – theboard
    Commented Mar 19, 2023 at 6:48
  • I added my manual attempt to call org-babel-execute-src-block to the question.
    – theboard
    Commented Mar 19, 2023 at 7:03

1 Answer 1

0

Find a way to check if python is available from emacs. I ran it on Windows and Emacs 29 and it yielded:

* #+RESULTS:
* : 2
2
  • Thanks, so it's not to do with Windows it seems. I edited the question where I manually call org-babel-execute-src-block with "python" as the language, and it does seem to "work" in the sense that it evaluated the code it seems but couldn't insert the result.
    – theboard
    Commented Mar 19, 2023 at 7:03
  • I would take commands from the error and try and run it. Start with small commands and then form bigger chunks, until I have an MRE. Possibly check how debugging works. If you have time and desire to drill it down, of course. I'm not an expert on emacs, that's why my answer is so vague :) But I hope I'm pushing you in the right direction.
    – merinoff
    Commented Mar 19, 2023 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.