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"]
        }
    ]
}
相关推荐
大聪明-PLUS13 分钟前
面向开发者的实用 GNU/Linux 命令(第二部分)
linux·嵌入式·arm·smarc
知远同学4 小时前
Anaconda的安装使用(为python管理虚拟环境)
开发语言·python
Blossom.1184 小时前
AI编译器实战:从零手写算子融合与自动调度系统
人工智能·python·深度学习·机器学习·flask·transformer·tornado
sorry#5 小时前
top简单使用
linux·运维
热爱专研AI的学妹5 小时前
数眼搜索API与博查技术特性深度对比:实时性与数据完整性的核心差异
大数据·开发语言·数据库·人工智能·python
QQ__17646198245 小时前
Ubuntu系统创建新用户与删除用户
linux·运维·服务器
Mr_Chenph6 小时前
Miniconda3在Windows11上和本地Python共生
开发语言·python·miniconda3
渣渣盟6 小时前
Linux邮件服务器快速搭建指南
linux·服务器·开发语言
6极地诈唬6 小时前
【PG漫步】DELETE不会改变本地文件的大小,VACUUM也不会
linux·服务器·数据库
ArrebolJiuZhou6 小时前
00 arm开发环境的搭建
linux·arm开发·单片机·嵌入式硬件