vscode在python-Debug种使用conda虚拟环境的解释器,以及args的配置。

文章目录

问题背景

使用ctrl+F5调用vscode调用python进行debug时,没有办法使用conda的虚拟环境的解释器,很多包用不了,另外命令行参数没有带上去(--xxx这样的)。

解决

注意首先找到debugger对应的launch.json文件。

第一个问题-虚拟环境解释器

在launch.json中添加:

bash 复制代码
"pythonPath": "虚拟环境解释器路径",

第二个问题-args

按照下面的格式在添加(举例):

bash 复制代码
"args": ["-b", "configs/env.yaml",
                    "-t","True",
                    "--gpus","1"]

我实际用的时候发现好像要换行,还有""的使用也要注意。

一个示例json

json 复制代码
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: Current File",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "pythonPath": "/xxx/python",
            "args": ["-b", "/xxx/env.yaml",
                     "-t","True",
                    "--gpus","1"]
        }
    ]
}
相关推荐
databook14 小时前
Manim实现脉冲闪烁特效
后端·python·动效
程序设计实验室15 小时前
2025年了,在 Django 之外,Python Web 框架还能怎么选?
python
倔强青铜三16 小时前
苦练Python第46天:文件写入与上下文管理器
人工智能·python·面试
用户25191624271120 小时前
Python之语言特点
python
刘立军20 小时前
使用pyHugeGraph查询HugeGraph图数据
python·graphql
数据智能老司机1 天前
精通 Python 设计模式——创建型设计模式
python·设计模式·架构
CYRUS_STUDIO1 天前
用 Frida 控制 Android 线程:kill 命令、挂起与恢复全解析
android·linux·逆向
数据智能老司机1 天前
精通 Python 设计模式——SOLID 原则
python·设计模式·架构
c8i1 天前
django中的FBV 和 CBV
python·django
c8i1 天前
python中的闭包和装饰器
python