Why is evaluation of this python code block disabled in emacs org mode?

3.8k Views Asked by At

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?

2

There are 2 best solutions below

0
On

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.

3
On

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.