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"]
        }
    ]
}
相关推荐
无心水4 分钟前
【Stable Diffusion 3.5 FP8】1、Stable Diffusion 3.5 FP8 入门指南:为什么它能颠覆文生图效率?
人工智能·python·深度学习·机器学习·stable diffusion·ai镜像开发·ai镜像
许商8 分钟前
【stm32】cmake构建vscode开发环境(复杂大型项目)
ide·vscode·编辑器
3824278279 分钟前
python:单例模式
开发语言·python·单例模式
摸鱼仙人~10 分钟前
一文详解text2vec库
开发语言·python
厚国兄11 分钟前
esp32+vscode,在vscode底部不显示esp32的命令图标问题解决
ide·vscode·编辑器
小女孩真可爱14 分钟前
大模型学习记录(九)-------Agent
人工智能·pytorch·深度学习·学习·大模型
natide16 分钟前
词汇/表达差异-6-n-gram分布距离
人工智能·python·算法
Yolo566Q17 分钟前
环境多介质逸度模型实践技术与典型案例【代码】应用
python
饕餮争锋18 分钟前
pip install 报错This environment is externally managed
开发语言·python·pip
superman超哥20 分钟前
仓颉语言导入语句使用深度解析
c语言·开发语言·c++·python·仓颉