编程语言
首页 > 编程语言> > macos – 如何在OS X 10.8.2上正确设置Python3.3和Sublime Text 2?

macos – 如何在OS X 10.8.2上正确设置Python3.3和Sublime Text 2?

作者:互联网

我正在尝试设置Sublime Text 2,以便build命令正确运行Python3 / Python3.3脚本.

我已经通过从python.org获得的安装程序安装了Python 3.3,并通过Sublime Text 2安装程序安装了Sublime Text 2.

接下来我添加了一个名为的自定义构建条目:

Python3.sublime-build 

进入Sublime Text 2的Python文件夹,其中包含以下内容:

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

尝试运行脚本时出现以下错误:

[Errno 2] No such file or directory
[cmd:  [u'python3', u'-u', u'/Users/user/Library/Application Support/Sublime Text 2/Packages/Python/Python3.sublime-build']]
[dir:  /Users/user/Library/Application Support/Sublime Text 2/Packages/Python]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
[Finished]

我已经读过/usr/bin中的symlinkng python3可能解决了这个问题,但是在通过Finder在/usr/bin中创建了符号链接之后,Sublime Text仍然无法构建,因为它获得了权限错误.

将Sublime Text 2设置为允许运行Python3脚本的最佳方法是什么?

[编辑]

如果我为安装生成的python3 simlink放置PATH,Sublime Text 2可以构建脚本,

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

但是当我尝试将PATH添加到〜/ .MacOSX / environment.plist时,如果没有定义的PATH,我就会收到错误.任何人都可以指出为什么这不起作用?

解决方法:

将“path”:“/ Library / Frame /Python.framework / Version / 3.3 / bin /”添加到Python3构建文件中.我看起来像这样:

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

注意:确保Python3的路径与您的机器相关 – 这对我来说是正确的

标签:python,macos,text-editor,sublimetext
来源: https://codeday.me/bug/20190818/1691940.html