![](/img/trans.png)
[英]Mac Yosemite os variable works in bash Python interpreter, running the script in terminal, but not in Sublime Text 2 text editor
[英]```bash: xterm: command not found``` when running Python, Sublime Text 3 (Mac)
我想在 Sublime Text 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\""
}
}
]
}
我輸入 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 網站下載 XQuartz: https ://www.xquartz.org 並安裝 XQuartz。 這解決了我的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.