VSCode用以Python开发的配置 | VSCode

VSCode编辑器实用插件

配置:
{
    "workbench.startupEditor": "newUntitledFile",
    "editor.minimap.enabled": false,
    "debug.inlineValues": true,
    "files.autoSave": "afterDelay",
    "python.terminal.executeInFileDir": true,
    "editor.maxTokenizationLineLength": 100000,
    "workbench.list.openMode": "doubleClick",
    "python.formatting.provider": "none",
    "scm.autoReveal": false,
    "debug.console.fontSize": 11.7,
    "debug.internalConsoleOptions": "neverOpen",
    "terminal.integrated.fontSize": 11.7,
    "explorer.autoReveal": false,
    "[python]": {
        "editor.defaultFormatter": "ms-python.python"
    },
    "[html]": {
        "editor.defaultFormatter": "HookyQR.beautify"
    },
    "workbench.editorAssociations": {
        "*.ipynb": "jupyter-notebook"
    },
    "notebook.cellToolbarLocation": {
        "default": "right",
        "jupyter-notebook": "left"
    },
    "workbench.iconTheme": "webstorm-icons",
    "scm.inputFontSize": 11.7,
    "markdown.preview.fontSize": 11.7,
    "explorer.confirmDelete": false,
    "editor.fontSize": 11.7,
    "editor.matchBrackets": false,
    "[json]": {
        "editor.defaultFormatter": "HookyQR.beautify"
    },
    "terminal.integrated.cursorStyle": "line",
    "terminal.integrated.tabs.focusMode": "singleClick",
    "terminal.integrated.inheritEnv": false,
    "editor.suggestSelection": "first",
    "files.exclude": {
        "**/.classpath": true,
        "**/.project": true,
        "**/.settings": true,
        "**/.factorypath": true
    },
    "python.showStartPage": false,
    "redhat.telemetry.enabled": false,
    "[javascript]": {
        "editor.defaultFormatter": "HookyQR.beautify"
    },
    "workbench.colorTheme": "Ultraedit Light",
    "python.languageServer": "Pylance",
    "python.analysis.completeFunctionParens": true,
    "window.zoomLevel": -1,
    "pyqt-integration.pyuic.cmd": "/opt/anaconda3/envs/qt_py36/bin/pyuic5",
    "pyqt-integration.qtdesigner.path": "/opt/anaconda3/envs/qt_py36/bin/",
    "tabnine.experimentalAutoImports": true,
    "editor.renderIndentGuides": false,
    "python.autoComplete.extraPaths": [
    ],
}
- 重点配置:在Scrapy或者Django项目中,单独执行某一个脚本,但需要导入项目中其他模块的对象,报错:ModuleNotFoundError
  + 需要在脚本执行前将当前workspace加入到python解释器可以读取的环境变量中
  + 措施:配置launch.json参数:
"env": {"PYTHONPATH": "${workspaceRoot}"}
{
    "configurations": [{
        "name": "Py: 当前文件",
        "type": "python",
        "request": "launch",
        "program": "${file}",
        "env": {"PYTHONPATH": "${workspaceRoot}"},
        "console": "integratedTerminal"
    }]
}

记录自己的学习历程!
原文地址:https://www.cnblogs.com/pymkl/p/12811574.html