python - Emacs 中的 Python 2 和 3

标签 python emacs python-3.x

我一直在使用 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,具体取决于我使用的语言?例如,C-c C-c 当前运行缓冲区,但它总是调用 python2.6,即使我正在编写 Python 3 代码。

最佳答案

如果您使用的是 python-mode.el,您可以尝试更改 py-which-shell。为了在每个文件的基础上执行此操作,您可以放置​​

# -*- py-which-shell: "python3"; -*-

在文件的第一行 - 如果第一行以 #! 开头,则在第二行。 另一种选择是放

# Local Variables:
# py-which-shell: "python3" 
# End: 

在文件的末尾。也许您应该给出 python3 的完整路径,而不仅仅是“python3”。

关于python - Emacs 中的 Python 2 和 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/501626/

相关文章:

python - Flask 中的数据库迁移 - sqlalchemy

python - 更改 python 打打印新率

python - 抓取无限滚动页面

python - ParserError : Error tokenizing data. C 错误 : Expected 7 fields in line 4, 在读取 csv 文件 pandas 时看到 10 个错误

emacs:使用正则表达式有选择地选择在哪些缓冲区上执行添加 Hook

linux - emacs shell 错误地解释 ipython 字符

visual-studio - 如何在 Microsoft Visual C# 2008 Express Edition 中启用 Emacs 键绑定(bind)?

python - 无法使用 Python 3.6 在 Mac 上安装 python-levenshtein 包

python-3.x - 在 Python 3 中重新打开关闭的 stringIO 对象

python - 配置 PyCharm IDE 以按照 Eclipse 的方式组织导入(Django 开发)