vscode在python-Debug种使用conda虚拟环境的解释器,以及args的配置。

问题背景

使用ctrl+F5调用vscode调用python进行debug时,没有办法使用conda的虚拟环境的解释器,很多包用不了,另外命令行参数没有带上去(–xxx这样的)。

解决

注意首先找到debugger对应的launch.json文件。

第一个问题-虚拟环境解释器

在launch.json中添加:

"pythonPath": "虚拟环境解释器路径",

第二个问题-args

按照下面的格式在添加(举例):

"args": ["-b", "configs/env.yaml",
                    "-t","True",
                    "--gpus","1"]

我实际用的时候发现好像要换行,还有""的使用也要注意。

一个示例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"]
        }
    ]
}

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-27 09:06:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-27 09:06:02       100 阅读
  3. 在Django里面运行非项目文件

    2024-03-27 09:06:02       82 阅读
  4. Python语言-面向对象

    2024-03-27 09:06:02       91 阅读

热门阅读

  1. 【Python笔记-FastAPI】定时任务实现(APScheduler)

    2024-03-27 09:06:02       35 阅读
  2. .net core 将html 转为图片

    2024-03-27 09:06:02       32 阅读
  3. 使用 PointNet 和 PyTorch3D 进行点云分类

    2024-03-27 09:06:02       33 阅读
  4. QEMU安装和使用@Ubuntu(待续)

    2024-03-27 09:06:02       43 阅读