我一直在教自己python并开始使用python 2.7.5和Sublime Text 2.我最近注册了一个类,他们使用的是python 3.4。我下载并安装了python 3.4到我的Mac上,但是我很难搞清楚如何使Subpime Text使用python 3而不是2.7。我用..
import sys
print sys.version
确定哪个版本的python ST正在使用。它以2.7.5报告。
如何强制ST使用python 3?
如果我没有提供足够的信息,请不要犹豫。
答案 0 :(得分:17)
在Google上找到this。
创建文件~/.config/sublime-text-2/Packages/Python/Python3.sublime-build
:
{
"cmd": ["python3", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
然后,您应该可以选择Python3构建系统。
如果这不起作用,请尝试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/"
}
答案 1 :(得分:0)
For me worked creating the file ~/.config/sublime-text-2/Packages/Python/Python3.sublime-build:
{
"cmd": ["python3", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"encoding": "utf8",
"path": "/home/tercio/anaconda3/bin/"
}
The "path": "/home/tercio/anaconda3/bin/" is path that is installed the anaconda3 in my computer. Replace this information with her path.