MacOS在VS code上运行Python失败,通过更改pythonPath解决
问题描述
安装完成python后,默认的运行python命令是python3
,而VSCode上默认命令是python
解决办法
在file\preference\settings下(或使用快捷键Ctrl + ,),搜索python.pythonPath
然后点击Add Item,加入
"python.pythonPath" = "python3"
再修改一下调试
结束之后保存
紧接着添加自定义的任务运行器:
在工作目录下的.vscode\
文件夹下,新建tasks.json
,输入以下代码:
{
"version": "2.0.0",
"tasks": [
{
"label": "Run Python file",
"type": "shell",
"command": "python3",
"args": [
"-u",
"${file}"
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"problemMatcher": []
}
]
}
本文来自博客园,作者:lamaper,转载请注明原文链接:https://www.cnblogs.com/lamaper/p/18459123