问题描述
我一直在使用Emacs来编写Python 2代码。现在我的系统上安装了Python 2.6和3.0,我也需要编写Python 3代码。以下是不同版本的设置/ usr / bin:
python - > python2.6 *
python2 - > python2.6 *
python2.6 *
python3 - > python3.0 *
python3.0 *
有没有办法设置这样Emacs使用正确的Python版本,具体取决于我使用的是哪种语言?例如,Cc Cc目前运行缓冲区,但总是调用python2.6,即使我正在编写Python 3代码。
p>如果您使用的是python-mode.el,您可以尝试更改 py-which-shell
。为了在每个文件的基础上执行此操作,您可以将
# - * - py-which-shell:python3 ; - 在文件的第一行 - 或 - 如果第一行开始的第二行 - * -
与#!
。
另一个选择是将
#本地变量:
#py-which-shell:python3
#End:
在文件的末尾。也许你应该给python3而不是python3的完整路径。
I have been using Emacs to write Python 2 code. Now I have both Python 2.6 and 3.0 installed on my system, and I need to write Python 3 code as well.
Here is how the different versions are set up in /usr/bin:
python -> python2.6*
python2 -> python2.6*
python2.6*
python3 -> python3.0*
python3.0*
Is there any way to set this up so that Emacs uses the correct version of Python, depending on which language I am using? For instance, C-c C-c currently runs the buffer, but it always calls python2.6, even if I am writing Python 3 code.
If you are using python-mode.el you can try to change py-which-shell
. In order to do this on a per-file basis you can put
# -*- py-which-shell: "python3"; -*-
at the first line of your file - or at the second line if the first line starts with #!
.Another choice is to put
# Local Variables:
# py-which-shell: "python3"
# End:
at the end of your file. Perhaps you should give the full path to python3 instead of just "python3".
这篇关于Emacs中的Python 2和3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!