在Ubuntu20.04上的VS代码中,当我按F5运行python脚本时,我得到:
“调试配置中的Python路径无效。”
下面是我的launch.json的相关部分:
"configurations": [
{
"name": "Python: Current File (Integrated Terminal)",
"type": "python",
"python": "/home/ian/anaconda3/bin/python3",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},我有正确的调试配置设置:

当我运行/home/ian/anaconda3 3/bin/python3 3时,它工作正常。
无论它的价值是什么,在综合终端中
which python和
which python3返回/回家/ian/anaconda3 3/bin/python (3)
如何让VS代码运行python?
发布于 2022-09-28 13:21:13
您可以尝试这种配置,它适用于我:
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true
}
]PS:正如Omroth所说,我以前选择了一个解释器,所以我不需要在python中指定launch.json命令。
如果您需要选择Python解释器,请使用快捷方式"Ctrl+Shift+P“并键入"Python: Select解释器”。

https://stackoverflow.com/questions/73881717
复制相似问题