Emacs中的Python 2和3都是如此
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.
我一直在使用Emacs编写Python 2代码。现在我的系统上安装了Python 2.6和3.0,我也需要编写Python 3代码。
Here is how the different versions are set up in /usr/bin:
以下是在/ 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.
有没有办法设置它,以便Emacs使用正确版本的Python,具体取决于我使用的语言?例如,C-c C-c当前运行缓冲区,但它总是调用python2.6,即使我正在编写Python 3代码。
5 个解决方案
#1
10
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
如果您使用的是python-mode.el,可以尝试更改py-which-shell。为了在每个文件的基础上执行此操作,您可以放置
# -*- 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".
在你的文件的末尾。也许你应该给python3的完整路径而不仅仅是“python3”。
更多相关文章
- python 操作excel 读写同一个文件
- 自动完成在VS代码和Python中的自动化对象
- 使用自定义qemu二进制文件与libvirt失败?
- 【python coding 1:网络检测】ping本地文件里的ip地址
- 如何输出NLTK块到文件?
- python 读写文本文件
- 批量重命名文件——python实现
- 在生产中是否应该减少服务器代码?
- Django:测试成功加载静态文件