如何设置python sublime text使用哪个版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23161604/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 02:22:17  来源:igfitidea点击:

How to set which version of python sublime text uses

pythonmacospython-3.xsublimetext2sublimetext

提问by Wyze

I have been teaching myself python and started out using python 2.7.5 and Sublime Text 2. I recently enrolled in a class and they are using python 3.4. I downloaded and installed python 3.4 onto my mac, but am having trouble figuring out how to make Sublime Text use python 3 instead of 2.7. I used..

我一直在自学 python 并开始使用 python 2.7.5 和 Sublime Text 2。我最近参加了一个课程,他们使用的是 python 3.4。我将 python 3.4 下载并安装到我的 mac 上,但是我无法弄清楚如何让 Sublime Text 使用 python 3 而不是 2.7。我用了..

import sys
print sys.version

to determine which version of python ST was using. It reports back with 2.7.5.

确定使用的是哪个版本的python ST。它报告了 2.7.5。

How do I force ST to use python 3?

如何强制 ST 使用 python 3?

If I have not included enough information, please don't hesitate to ask.

如果我没有提供足够的信息,请不要犹豫,问。

采纳答案by Ryan P

Found thison Google.

在谷歌上找到了这个

Create the file ~/.config/sublime-text-2/Packages/Python/Python3.sublime-build:

创建文件~/.config/sublime-text-2/Packages/Python/Python3.sublime-build

{
    "cmd": ["python3", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}

You should then be able to choose the Python3 build system.

然后您应该可以选择 Python3 构建系统。

If that doesn't work, try this:

如果这不起作用,请尝试以下操作

{
    "cmd": ["python3", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
    "encoding": "utf8",
    "path": "/Library/Frameworks/Python.framework/Versions/3.3/bin/"
}