menu Chancel's blog
rss_feed
Chancel's blog
时来天地皆同力

VSCode在launch.json中自定义Python解释器位置

作者:Chancel Yang, 时间:2022 May 19, 阅读:76

因项目需要,在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"

        }
    ]
}

[[replyMessage== null?"发表评论":"发表评论 @ " + replyMessage.m_author]]

account_circle
email
web_asset
textsms

评论列表([[messageResponse.total]])

还没有可以显示的留言...
[[messageItem.m_author]] [[messageItem.m_author]]
[[messageItem.create_time]]
[[getEnviron(messageItem.m_environ)]]
[[subMessage.m_author]] [[subMessage.m_author]] @ [[subMessage.parent_message.m_author]] [[subMessage.parent_message.m_author]]
[[subMessage.create_time]]
[[getEnviron(messageItem.m_environ)]]