[英]get vscode debug running from a specific python.exe path
我尝试让 VS 代码调试( F5
键)从与Run Python File
相同的位置运行。
运行代码路径在这里:
c:/Users/Username/.Tactical/Local/envs/lon/python.exe
到目前为止我已经厌倦了(与上一个问题相比): 在 VS 代码中运行 python 脚本适用于运行 python 文件按钮,但不是 F5 键
我现在希望将launch.json
明确指向同一路径。
launch.json 配置如下所示:
{
"name": "Python: Base Console", // i am tesing this.
"type": "python",
"request": "launch",
"program": "${file}", // can the user change this line to the correct python.exe ?
"console": "integratedTerminal"
}
我试图将${file}
更改为路径,但这失败了。 我是否正确理解了这一点,或者我应该怎么做才能指向正确的python.exe
?
launch.json
中的"program"
配置是程序的入口模块。
如果要指定python解释器进行调试,请使用"python"
配置。
一个简单的例子:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".venv",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
"python": "C:\\WorkSpace\\PyTest0628\\.venv\\Scripts\\python.exe"
},
{
"name": "anaconda",
"type": "python",
"request": "launch",
"program": "C:\\WorkSpace\\PyTest0628\\Test6.py",
"console": "integratedTerminal",
"justMyCode": true,
"python": "C:\\Users\\Admin\\anaconda3\\python.exe"
}
]
}
您可以在调试窗口中选择要使用的配置:
有关launch.json
更多配置信息: https ://code.visualstudio.com/docs/python/debugging#_set-configuration-options
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.