From: Eric Schulte <schulte.eric@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: wrong python version when using :session
Date: Mon, 05 Sep 2011 11:35:37 -0600 [thread overview]
Message-ID: <87vct6q4d2.fsf@gmail.com> (raw)
In-Reply-To: <87liu2x5jr.fsf@bill.home> (Myles English's message of "Mon, 05 Sep 2011 18:28:08 +0100")
Hi Myles,
The `org-babel-python-command' variable is used to decide which python
executable is used to run non-interactive python code. Session
evaluation is performed using the interactive python mode defined in the
`org-babel-python-mode' variable.
,----
| org-babel-python-mode is a variable defined in `ob-python.el'.
| Its value is python
|
| Documentation:
| Preferred python mode for use in running python interactively.
| This will typically be either 'python or 'python-mode.
|
| [back]
`----
From there the selected interactive python back-end is responsible for
all python interaction and you would want to look at the relevant
documentation for that tool to find out how to specify which flavor of
python is used.
Hope this helps -- Eric
Myles English <mylesenglish@gmail.com> writes:
> Hello,
>
> When a python source block has a :session header argument, the python
> version selected does not appear to respect the value of the variable
> org-babel-python-command.
>
>
> Starting emacs with this in the init file (.emacs):
>
> (require 'org-install)
>
> (org-babel-do-load-languages
> 'org-babel-load-languages
> '((python . t) ))
>
> (setq org-babel-python-command "python2")
>
>
> And in my org file:
>
> #+begin_src python :results output
> import sys
> print(sys.version)
> #+end_src
>
> #+results:
> : 2.7.2 (default, Jun 29 2011, 11:10:00)
> : [GCC 4.6.1]
>
> Now, exactly the same but with ":session x" header argument:
>
> #+begin_src python :results output :session x
> import sys
> print(sys.version)
> #+end_src
>
> #+results:
> :
> : 3.2.1 (default, Jul 11 2011, 12:37:47)
> : [GCC 4.6.1]
>
> So babel has chosen to use Python 3.2 When I wanted to use Python 2.7,
> as in the first block, and the value of org-babel-python-command is
> still "python2".
>
> Part of the documentation for the variable python-python-command is:
> "Shell command to run Python interpreter". On my system to run the
> Python 2.7 interpreter I would do:
>
> $ python2
>
> at the command line so, setting this variable thus:
>
> #+begin_src elisp
> (setq python-python-command "python2")
> #+end_src
>
> #+results:
> : python2
>
> and then using the two examples from above again gives the same
> (correct) results for the block without the :session header argument:
>
> #+begin_src python :results output
> import sys
> print(sys.version)
> #+end_src
>
> #+results:
> : 2.7.2 (default, Jun 29 2011, 11:10:00)
> : [GCC 4.6.1]
>
> but a different error for the block with the session argument:
>
> #+begin_src python :results output :session x
> import sys
> print(sys.version)
> #+end_src
>
> results in the message:
>
> "python-check-version: Only Python versions >= 2.2 and < 3.0 are
> supported"
>
> Versions on my system are:
>
> orgmode commit cae9f947be (Aug 30th)
> GNU Emacs 23.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.22.1) of 2011-03-10 on bitzer.hoetzel.info
>
> $ ls -l `which python{2,3,}`
> /usr/bin/python -> python3
> /usr/bin/python2 -> python2.7
> /usr/bin/python3
>
> Am I doing something wrong or is this a bug? I am wondering if it is
> reasonable to expect emacs/orgmode to be able to deal with the fact that I
> have Python 3 installed.
>
> Thanks,
>
> Myles
>
--
Eric Schulte
http://cs.unm.edu/~eschulte/
next prev parent reply other threads:[~2011-09-05 17:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-05 17:28 wrong python version when using :session Myles English
2011-09-05 17:35 ` Eric Schulte [this message]
2011-09-05 22:26 ` Myles English
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vct6q4d2.fsf@gmail.com \
--to=schulte.eric@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).