From mboxrd@z Thu Jan 1 00:00:00 1970 From: William Henney Subject: Re: [babel] Setting python interpreter version on per-block or per-subtree basis Date: Fri, 25 Apr 2014 11:29:59 -0500 Message-ID: References: <87bnvp2zsp.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=089e0122f7241153bb04f7e07a1e Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wdj0j-0003uP-V3 for emacs-orgmode@gnu.org; Fri, 25 Apr 2014 12:30:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wdj0i-00020s-Jm for emacs-orgmode@gnu.org; Fri, 25 Apr 2014 12:30:01 -0400 Received: from mail-ie0-x236.google.com ([2607:f8b0:4001:c03::236]:35227) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wdj0i-00020f-Bj for emacs-orgmode@gnu.org; Fri, 25 Apr 2014 12:30:00 -0400 Received: by mail-ie0-f182.google.com with SMTP id tp5so662669ieb.41 for ; Fri, 25 Apr 2014 09:29:59 -0700 (PDT) In-Reply-To: <87bnvp2zsp.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: emacs-org --089e0122f7241153bb04f7e07a1e Content-Type: multipart/alternative; boundary=089e0122f7241153b604f7e07a1c --089e0122f7241153b604f7e07a1c Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Dear Sacha, Ian, and Eric Thanks very much for your replies. Sacha's way is a clever idea and works fine, but I think Eric's patch is the best solution in the long term. Please see attached test file - the patch works perfectly. Although I did have to study the manual carefully to work out how get it to work using the #+call: syntax. The key is to use "inside header arguments". Ian's solution with shebang works when tangling but not for direct evaluation of the source block. Cheers Will On Fri, Apr 25, 2014 at 10:27 AM, Eric Schulte wrot= e: > The attached patch should allow the specification of the python command > through a new :python header argument. E.g., > > #+begin_src python :python /path/to/python2 > return 1 + 2 > #+end_src > > If someone who actually uses python could confirm that it works as > expected then I'll be happy to apply it. > > > > Best, > Eric > > William Henney writes: > > > Hi > > > > Is there an easy way to specify the python version to use for a > particular > > block or sub-tree? > > > > My use case is that I have mainly migrated to python 3, but there is > still > > the occasional library that has not been updated yet, so I need to fall > > back to python 2.7 for some tasks. > > > > I can work around the problem by putting the python 2 code in a separat= e > > org file and use > > > > # Local Variables: > > # org-babel-python-command: "/path/to/python2" > > # End: > > > > but keeping everything in the same file would be preferable. > > > > Thanks > > > > Will > > -- > Eric Schulte > https://cs.unm.edu/~eschulte > PGP: 0x614CA05D > > --=20 Dr William Henney, Centro de Radioastronom=C3=ADa y Astrof=C3=ADsica, Universidad Nacional Aut=C3=B3noma de M=C3=A9xico, Campus Morelia --089e0122f7241153b604f7e07a1c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Dear Sacha, Ian, and Eric

Thanks very m= uch for your replies. =C2=A0Sacha's way is a clever idea and works fine= , but I think Eric's patch is the best solution in the long term. =C2= =A0Please see attached test file - the patch works perfectly. =C2=A0Althoug= h I did have to study the manual carefully to work out how get it to work u= sing the #+call: syntax. The key is to use "inside header arguments&qu= ot;. =C2=A0Ian's solution with shebang works when tangling but not for = direct evaluation of the source block.

Cheers

Will







--

=C2= =A0 Dr William Henney, Centro de Radioastronom=C3=ADa y Astrof=C3=ADsica,=C2=A0 Universidad Nacional Aut=C3=B3noma de M=C3=A9xico, Campus Morelia
--089e0122f7241153b604f7e07a1c-- --089e0122f7241153bb04f7e07a1e Content-Type: application/octet-stream; name="multi-python.org" Content-Disposition: attachment; filename="multi-python.org" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hufovvt11 VGVzdCBvZiBFcmljIFNjaHVsdGUncyBwYXRjaCB0by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