menu Chancel's blog
rss_feed
Chancel's blog
有善始者实繁,能克终者盖寡。

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

作者:Chancel Yang, 创建:2022-05-19, 字数:1434, 已阅:84, 最后更新:2022-05-19

这篇文章更新于 701 天前,文中部分信息可能失效,请自行甄别无效内容。

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

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

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"

修改后如下

JSON
{
    "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)]]