[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Mixing Python2 and Python3 blocks in one file

From: William Henney
Subject: Re: [O] Mixing Python2 and Python3 blocks in one file
Date: Tue, 17 May 2016 09:24:32 -0500

Hi Karl

On Sun, May 8, 2016 at 3:31 AM, Karl Voit <address@hidden> wrote:

Python2 and Python3 are two different languages. Unfortunately,
Org-mode only uses ~#+BEGIN_SRC python~ for both and uses
python-shell-interpreter to choose/switch the compiler.

Shouldn't Org-mode introduce ~#+BEGIN_SRC python2~ and ~#+BEGIN_SRC
python3~ to solve this issue in a clean way?

~#+BEGIN_SRC python~ can still default to python2.

You can use the :python header argument to the source block, which allows you to specify the path to the python interpreter:

————————— BEGIN EXAMPLE ———————— 

* Default python version
#+name: check-python-version
#+BEGIN_SRC python
import sys
return sys.version

#+RESULTS: check-python-version
: 3.4.4 |Anaconda 2.5.0 (x86_64)| (default, Jan  9 2016, 17:30:09) 
: [GCC 4.2.1 (Apple Inc. build 5577)]

This is the control experiment. 

* Custom python version
#+BEGIN_SRC python :python /Users/will/anaconda/envs/py27/bin/python
import sys
return sys.version

: 2.7.11 |Continuum Analytics, Inc.| (default, Dec  6 2015, 18:57:58) 
: [GCC 4.2.1 (Apple Inc. build 5577)]

—————————  END EXAMPLE  ———————— 

Also see original discussion at



I only found those sources/solutions:

... file-variables to choose interpretor

... workaround with #+srcname (I don't get yet)

mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode:
       > get Memacs from https://github.com/novoid/Memacs <

https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on github


  Dr William Henney, Instituto de Radioastronomía y Astrofísica,
  Universidad Nacional Autónoma de México, Campus Morelia

reply via email to

[Prev in Thread] Current Thread [Next in Thread]