vscode (Visual Studio Code) 配置Python 虛擬環境

配置run 運行相關

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: 當前文件",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "cwd": "${workspaceRoot}",
            "console": "integratedTerminal",
            "env": {"PYTHONPATH":"${workspaceRoot}"}
        }
    ]
}

code runner 配置

settings.json

{
    "python.pythonPath": "venv\\Scripts\\python.exe",
    "code-runner.executorMap": {
        "python": "$pythonPath -u $fullFileName",
    },
    "code-runner.saveFileBeforeRun": true,
    "code-runner.runInTerminal": true,
    // 將項目路徑添加到python path變量中
    "terminal.integrated.env.windows": {
        "PYTHONPATH":"${workspaceRoot}"
    },

    // 單元測試
    "python.testing.pytestArgs": [
        "test"
    ],
    "python.testing.unittestEnabled": false,
    "python.testing.nosetestsEnabled": false,
    "python.testing.pytestEnabled": false,
    "python.testing.promptToConfigure": false
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章