我想在Sublime文本3上运行Python代码。我这样做是为了运行需要用户输入的程序。
1-我安装了" packageresourceviewer"
2-在命令调色板中我输入并选择了" Packageresourceviewer:Open Resource"
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""
}
}
]
}
i类型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
从Xquartz Web下载Xquartz:https://www.xquartz.org并安装Xquartz。这解决了我的问题。