python - 如何配置 vscode 的 python 调试器以使用项目的终端而不是全局?
问题描述
将 python 调试器与 vscode 一起使用时,我希望它使用我在项目中选择的终端settings.json
,而不是全局定义的终端。
具体来说,我将 WSL 的终端定义为 vscode 使用的默认终端,并将我的 python 项目配置为使用带有 anaconda 的 windows cmd。当我尝试使用集成终端调试 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
文件更改为 use "console": "internalConsole"
,这允许软件运行,但我无法调试任何东西,断点不起作用等。
解决方案
推荐阅读
- java - 无法从 Bosch IoT API 获取数据
- android - RecyclerView 中 CardView 项的滚动位置
- c# - 即使禁用控件,ObjectListView 也允许垂直滚动?
- arrays - 将项目添加到角度材料表
- r - 初学者:在 R 中设置时间序列
- email - 垃圾邮件过滤器正在影响电子邮件打开率
- asynchronous - 使用 Camel 的异步非阻塞组播
- python - Sort array by specific column then sort by value of this column
- c# - 使用具有不同类型的多个对象反序列化 JSON 类
- azure - Azure DevOps - 从传入电子邮件创建工作项