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"]
        }
    ]
}
相关推荐
小学鸡!几秒前
部署jar包时指定配置文件
java·python·jar
南_山无梅落2 分钟前
7.1-Python3序列:列表(list)与元组(tuple)核心操作
开发语言·python
Q_Q5110082853 分钟前
python+springboot+django/flask时尚内衣销售数据可视化和预测系统
spring boot·python·django·flask·node.js·php
starvapour4 分钟前
替换Ubuntu各种命令的默认编辑器
linux·ubuntu·编辑器
滴答滴答嗒嗒滴5 分钟前
Windows无法识别SD卡?SD卡刷这个镜像之后,用读卡器插电脑识别不到了
linux·ubuntu·电脑
qq_479875435 分钟前
深入解析 Protobuf 消息的分帧 (Framing) 与编码 (Codec)
linux·c++
川川菜鸟6 分钟前
多域名 · 多节点 · 自动择优访问
python
Frank学习路上6 分钟前
【Linux】tcpdump抓包工具与wireshark介绍
linux·wireshark·tcpdump
C嘎嘎嵌入式开发7 分钟前
【NLP实战项目:中文文本分类】数据集THUCNews
人工智能·python·机器学习·自然语言处理
by__csdn7 分钟前
第二章 (.NET Core环境搭建)第二节( Visual Studio Code)
ide·vscode·c#·vue·asp.net·.net·.netcore