因项目需要,在src下有server与client2个文件夹,有各自的第三方引用库,将env放置在项目外并不合适

想在src/server和src/client中各自放置一个python env环境,在launch.json中原配置如下

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Server Main",
            "type": "python",
            "request": "launch",
            "program": "${workspaceRoot}/src/server/main.py",
            "console": "internalConsole"
        },
        {
            "name": "Python: Client Main",
            "type": "python",
            "request": "launch",
            "program": "${workspaceRoot}/src/client/main.py",
            "console": "internalConsole"
        }
    ]
}

自定义Server和Client的启动环境,需在Server与Client节点中添加

"python": "${workspaceRoot}/src/server/.env/bin/python3"

修改后如下

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Server Main",
            "type": "python",
            "request": "launch",
            "program": "${workspaceRoot}/src/server/main.py",
            "console": "internalConsole",
            "python": "${workspaceRoot}/src/server/.env/bin/python3"
        },
        {
            "name": "Python: Client Main",
            "type": "python",
            "request": "launch",
            "program": "${workspaceRoot}/src/client/main.py",
            "console": "internalConsole",
            "python": "${workspaceRoot}/src/client/.env/bin/python3"

        }
    ]
}