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"]
        }
    ]
}
相关推荐
zfj3214 分钟前
vscode是js开发的,为什么能支持golang java等各种语言开发
javascript·vscode·golang
清水白石00823 分钟前
《Python × 数据库:用 SQLAlchemy 解锁高效 ORM 编程的艺术》
开发语言·python·json
^乘风破浪^29 分钟前
Ubuntu部署Xingrin(星环)企业级漏洞扫描与资产管理平台
linux·运维·ubuntu
Lueeee.29 分钟前
内核模块符号的导出
linux·运维·服务器
星依网络30 分钟前
使用LabelImg工具标注数据(游戏辅助脚本开发)
python·游戏引擎·图形渲染·骨骼绑定
站大爷IP30 分钟前
Appium实现Android应用数据爬取:从环境搭建到实战优化
python
C语言魔术师43 分钟前
【linux】linux进程概念(四)(环境变量)
linux·运维·服务器
松涛和鸣44 分钟前
DAY32 Linux Thread Programming
linux·运维·数据库·算法·list
eggrall1 小时前
《gdb 与 cgdb 深度解析:命令行调试的效率革命》
linux
IT老兵20251 小时前
PyTorch DDP多GPU训练实践问题总结
人工智能·pytorch·python·分布式训练·ddp