Skip to main content Link Menu Expand (external link) Copy Copied

PY 环境配置

Table of contents

.vscode/.env 配置

PYTHONPATH="./;../../folder1;../folder2"

.vscode/launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": false,
            "envFile": "${workspaceFolder}/.vscode/.env" # 配置python环境变量文件位置
        }
    ]
}

.vscode/settings.json

{
    "python.languageServer": "Pylance",
    "editor.formatOnSave": true,
    "python.autoComplete.addBrackets": true,
    "python.autoComplete.extraPaths": [
        "./src", # 代码自动补全位置限制代码
        "folder1",
        "folder2"
    ],
    "python.analysis.extraPaths": [
        "./src", # 代码分析限制位置
        "folder1",
        "folder2"
    ],
    "python.jediEnable": false,
    "python.envFile": "${workspaceFolder}/.vscode/.env", # 同上,python环境变量文件位置
    "python.analysis.completeFunctionParens": true,
    "terminal.integrated.env.windows": {
        "PYTHONPATH": "${workspaceRoot}" # 配置控制台窗口的环境变量
    }
}