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"]
        }
    ]
}
相关推荐
chao_7898 分钟前
回溯题解——子集【LeetCode】二进制枚举法
开发语言·数据结构·python·算法·leetcode
行止616 分钟前
OpenStack云平台管理
linux·openstack
zdw30 分钟前
fit parse解析佳明.fit 运动数据,模仿zwift数据展示
python
岁岁岁平安1 小时前
CentOS-7-x86_64解决:使用NAT模式无法ping通www.baidu.com或无法ping 8.8.8.8问题。
linux·运维·centos·centos-7
剑桥折刀s1 小时前
Python打卡:Day46
python
运维小贺1 小时前
各服务器厂商调整BIOS睿频教程
linux·运维·服务器·性能优化
巴里巴气1 小时前
Python爬虫图片验证码和滑块验证码识别总结
爬虫·python
特种加菲猫1 小时前
指尖上的魔法:优雅高效的Linux命令手册
linux·笔记
★Orange★2 小时前
Linux Kernel kfifo 实现和巧妙设计
linux·运维·算法
sword devil9002 小时前
PYQT实战:智能家居中控
python·智能家居·pyqt