使用python2.7与Emacs 24.3和python-mode.el [英] Using python2.7 with Emacs 24.3 and python-mode.el
问题描述
哪个python
产生。在我的情况下,这是python 3.3.3。但是,由于我需要一个python 2.7 shell,我试图让Emacs在 C-c C-c
之间产生一个shell。不幸的是,我不清楚,怎么做到这一点。将 py-shell-name
设置为哪个python2.7
产生(即 / usr / bin / python2.7
)不起作用。如何获取Emacs来执行此操作,或者当我点击 Cc Cc
时,如何追踪Emacs的执行情况?python-mode.el,使用python2执行一个python缓冲区:
Mx py-execute- buffer-python2
或将其放在.emacs文件中:
(custom-set-variables
'(py-force-py-shell-name-p t)
'(py-shell-namepython2))
python-mode.el检查 py-force-py-shell-name-p执行
变量,如果此变量设置为true(t),则使用保存在 py-execute-buffer
(绑定到 Cc Cc
键)时的 py-shell-name
中的python解释器名称。
或者,这种定制可以在 Mx自定义
,编程>语言> Python模式中进行,在那里搜索Py Force Py Shell和Py Shell Name线。
它会将这个自定义代码添加到.emacs文件中。
Emacs help(describe function):
Ch f py-execute-buffer TAB
您可以将python缓冲区中的选定区域发送到任何解释者:
Cu 3 Mx py-execute-region
Emacs将会每次提示您要使用的python解释器名称。
前缀数字参数可以是除1或4之外的任何数字,否则将使用默认解释器,而不提示。
要在不同的python解释器中执行缓冲区您可以通过 Cx h
选择整个缓冲区,然后使用此前缀命令。
I'm new to Emacs and I'm trying to set up my python environment. So far I've learned that using "python-mode.el" in a python buffer C-c C-c
loads the contents of the current buffer into an interactive python shell, apparently using what which python
yields. In my case that is python 3.3.3. But since I need to get a python 2.7 shell, I'm trying to get Emacs to spawn such a shell on C-c C-c
. Unfortunatly I can't figure out, how to do this. Setting py-shell-name
to what which python2.7
yields (i.e. /usr/bin/python2.7
) does not work. How can get Emacs to do this, or how can I trace back what Emacs executes when I hit C-c C-c
?
python-mode.el, execute a python buffer using python2:
M-x py-execute-buffer-python2
or put this in .emacs file:
(custom-set-variables
'(py-force-py-shell-name-p t)
'(py-shell-name "python2"))
python-mode.el checks py-force-py-shell-name-p
variable when executing py-execute-buffer
(bound to C-c C-c
key), and if this variable is set to true("t"), then use python interpreter name saved in py-shell-name
.
Alternatively, this customization can be done in M-x customize
, Programming>Languages>Python Mode, search there for "Py Force Py Shell" and "Py Shell Name" lines.
It will add this customization code to your .emacs file.
Emacs help(describe function):
C-h f py-execute-buffer TAB
You can send selected region in a python buffer to any interpreter:
C-u 3 M-x py-execute-region
Emacs will prompt every time for a python interpreter name you want to use. The prefix numerical argument may be any number except 1 or 4, otherwise it will use a default interpreter without prompt.
To execute a buffer in different python interpreters you can select whole buffer by C-x h
and then use this prefixed command.
这篇关于使用python2.7与Emacs 24.3和python-mode.el的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!