运行Python,Sublime Text 3(Mac)时的``bash:xterm:命令未找到''

时间:2019-05-08 18:06:27

标签: python bash macos terminal sublimetext3

我想在Sublime Text 3上运行Python代码。这样做是为了运行需要用户输入的程序。

1-我安装了“ PackageResourceViewer”

2-在命令面板中,键入并选择“ PackageResourceViewer:打开资源”

3-然后我写了python,并在结果列表(Python)中选择了第一项

4-在弹出面板中,我选择了Python.sublime-build

5-打开的文件,我编写了以下代码行:

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

    "env": {"PYTHONIOENCODING": "utf-8"},

    "variants":
    [
        {
            "name": "Syntax Check",
            "shell_cmd": "python -m py_compile \"${file}\"",
        },

        {
            "name": "Run in console",
             "osx":{
                "shell_cmd": "xterm -hold -e python -u \"$file\""
            }

        }
    ]
}

我键入Shift-Cmd-B,选择Python并在终端上出现以下错误:

bash: xterm: command not found
[Finished in 0.2s with exit code 127]
[shell_cmd: xterm -hold -e python -u "/Users/kalebsamano/Desktop/Fun. Programacion/calculadora_ahorros.py"]
[dir: /Users/kalebsamano/Desktop/Fun. Programacion]
[path: /anaconda3/bin:/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]

我正在使用MacOS

1 个答案:

答案 0 :(得分:0)

从 XQuartz 网站下载 XQuartz:https://www.xquartz.org 并安装 XQuartz。这解决了我的问题。