6

In a python source block in org-mode, after hitting C-c C-c, emacs says

Evaluation of python source block is disabled

Could anyone explain why?

iamdave
  • 12,023
  • 3
  • 24
  • 53
sinestandly
  • 131
  • 2
  • 8
  • Do you have a minimal working example (i.e., a small code source block) that we could all try out to reproduce your exact issue? – lawlist Dec 31 '16 at 19:12

2 Answers2

11

Simon's answer is not right if the org-mode version is >= 9. Here is another question on the same problem.

The solution

cd .emacs.d
cd elpa
cd org-xxxx
rm *.elc

Then, it's better to byte-recompile the directory of the org-xxxx. To do that, start emacs, then

C-0 M-x byte-recompile-directory RET ~/emacs.d/elpa/org-xxxx

Details at here.

Update 1: EmacsWiki on compile file.

Alex Xu
  • 196
  • 2
  • 10
  • The link on the last line of your answer seems to be dead. – NickD Jun 05 '17 at 19:09
  • @Nick the link is to https://github.com/syl20bnr/spacemacs/issues/7641 I just checked it, it should work. BTW, More specifically, it is [this_comment](https://github.com/syl20bnr/spacemacs/issues/7641#issuecomment-262498640) – Alex Xu Jun 06 '17 at 14:34
  • Yup, it's working: whatever was happening yesterday (locally or remotely) seems to have fixed itself. – NickD Jun 06 '17 at 14:51
2

In order to evaluate an org-mode code block of a specific language you will have to customize org-babel-load-languages as described here. Evaluating the following will probably resolve your issue:

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

From the docs:

org-babel-load-languages is a variable defined in org.el. Original value was ((emacs-lisp . t))

Languages which can be evaluated in Org-mode buffers. This list can be used to load support for any of the languages below, note that each language will depend on a different set of system executables and/or Emacs modes. When a language is "loaded", then code blocks in that language can be evaluated with org-babel-execute-src-block bound by default to C-c C-c (note the org-babel-no-eval-on-ctrl-c-ctrl-c variable can be set to remove code block evaluation from the C-c C-c keybinding. By default only Emacs Lisp (which has no requirements) is loaded.

You can customize this variable.

This variable was introduced, or its default value was changed, in version 24.1 of Emacs.

Simon Fromme
  • 3,104
  • 18
  • 30