如何设置python sublime text使用的版本

2024-04-18 22:26:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在自学python,开始使用python 2.7.5和Sublime text2。我最近注册了一个类,他们正在使用Python3.4。我下载了Python3.4并将其安装到我的mac上,但是我很难弄清楚如何使Sublime文本使用Python3而不是2.7。我用过。。

import sys
print sys.version

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

如何强制ST使用python 3?

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


Tags: 文本import版本信息versionmac报告sys
1条回答
网友
1楼 · 发布于 2024-04-18 22:26:21

在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/"
}

相关问题 更多 >