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"]
        }
    ]
}
相关推荐
晚风予卿云月3 分钟前
【Linux】自动化构建—make/Makefile
linux·自动化·make/makefile
哈哈不让取名字9 分钟前
用Pygame开发你的第一个小游戏
jvm·数据库·python
程序员敲代码吗10 分钟前
Python异步编程入门:Asyncio库的使用
jvm·数据库·python
sunfove12 分钟前
Python小游戏:在 2048 游戏中实现基于线性插值(Lerp)的平滑动画
开发语言·python·游戏
2501_9445264217 分钟前
Flutter for OpenHarmony 万能游戏库App实战 - 抽牌游戏实现
android·开发语言·python·flutter·游戏
副露のmagic19 分钟前
python基础复健
python·算法
脑子进水养啥鱼?24 分钟前
Linux find 命令
linux·运维
学Linux的语莫28 分钟前
python项目打包为镜像
java·python·spring
梓䈑29 分钟前
【Linux系统】实现线程池项目(含日志类的设计)
linux·服务器·c++
Ashley_Amanda40 分钟前
Python 进阶:从熟练到精通的核心技能体系
开发语言·python