简体   繁体   中英

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

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

Evaluation of python source block is disabled

Could anyone explain why?

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.

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 Cc Cc (note the org-babel-no-eval-on-ctrl-c-ctrl-c variable can be set to remove code block evaluation from the Cc Cc 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM