在将Python调试器与vscode结合使用时,我希望它使用在项目settings.json
中选择的终端,而不是全局定义的终端。
具体地说,我将WSL的终端定义为vscode使用的默认终端,并且我将python项目配置为将Windows cmd与anaconda一起使用。当我尝试使用集成终端调试python项目时,它尝试使用WSL启动文件,最终失败。我希望调试器使用cmd。
我曾尝试在项目中调整launch.json
,但似乎无法在此文件中选择任意终端。
我的launch.json
文件如下:
{
// 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": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
产生以下结果:
C:/Users/Owner/Anaconda3/Scripts/activate
C:\Users\Owner\Anaconda3\python.exe c:\Users\Owner\.vscode\extensions\ms-python.python-2019.11.50794\pythonFiles\ptvsd_launcher.py --default --client --host localhost --port 50893 e:\Software\project\.vscode\launch.json
conda activate base
owner@computer:/mnt/e/Software/project$ C:/Users/Owner/Anaconda3/Scripts/activate
-bash: C:/Users/Owner/Anaconda3/Scripts/activate: No such file or directory
owner@computer:/mnt/e/Software/project$ C:\Users\Owner\Anaconda3\python.exe c:\Users\Owner\.vscode\extensions\ms-python.python-2019.11.50794\pythonFiles\ptvsd_launcher.py --default --client --host localhost --port 50893 e:\Software\project\.vscode\launch.json
C:UsersOwnerAnaconda3python.exe: command not found
owner@computer:/mnt/e/Software/project$ conda activate base
conda: command not found
owner@computer:/mnt/e/Software/project$
如果我将launch.json
文件更改为使用"console": "internalConsole"
,这允许软件运行,但是我无法调试任何东西,断点不起作用,等等。