Vscode安装python插件


Vscode安装python插件

🧩 一、核心必备插件(必须装)

插件名称 VS Code 标识符 安装命令 作用说明
Python ms-python.python code --install-extension ms-python.python Python 语言支持、调试、运行、环境选择的基础插件。
Pylance ms-python.vscode-pylance code --install-extension ms-python.vscode-pylance 高性能智能补全、类型推断、语法检查。建议与 Python 搭配使用。
Jupyter ms-toolsai.jupyter code --install-extension ms-toolsai.jupyter 支持 .ipynb 文件,内嵌 Jupyter Notebook。
Jupyter Keymap ms-toolsai.jupyter-keymap code --install-extension ms-toolsai.jupyter-keymap 优化 Notebook 快捷键。
Jupyter Cell Tags ms-toolsai.jupyter-cell-tags code --install-extension ms-toolsai.jupyter-cell-tags 增强 Notebook 单元管理体验。

💡 配置建议:
打开命令面板(Ctrl+Shift+P)→ 搜索 “Python: Select Interpreter” → 选择你想用的 Conda 或系统环境。


🧱 二、代码规范与格式化插件(提升质量)

插件名称 标识符 安装命令 功能
Black Formatter ms-python.black-formatter code --install-extension ms-python.black-formatter 自动格式化 Python 代码(官方推荐)
isort ms-python.isort code --install-extension ms-python.isort 自动排序 import 导入语句
Flake8 ms-python.flake8 code --install-extension ms-python.flake8 静态代码检查,帮助找出风格和潜在错误
Pylint ms-python.pylint code --install-extension ms-python.pylint 更全面的静态检查,适合大项目使用

🧩 推荐配置(settings.json):

{
  "editor.formatOnSave": true,
  "python.formatting.provider": "black",
  "python.linting.enabled": true,
  "python.linting.flake8Enabled": true,
  "python.linting.pylintEnabled": false,
  "isort.args": ["--profile", "black"]
}

🎨 三、界面与编辑增强插件

插件名称 标识符 功能
Better Comments aaron-bond.better-comments 高亮不同类型注释(例如:TODO, !, ?, *
indent-rainbow oderwat.indent-rainbow 彩色缩进,快速发现缩进错误
Error Lens usernamehw.errorlens 将错误和警告直接显示在代码中行尾
GitLens eamodio.gitlens 增强 Git 支持,查看每行提交者与历史
Material Icon Theme PKief.material-icon-theme 让文件图标更直观美观
One Dark Pro zhuangtongfa.Material-theme 非常舒服的主题(深色)

🧠 四、辅助生产力插件

插件名称 标识符 功能
autoDocstring njpwerner.autodocstring 快速生成函数/类的 docstring
Python Snippets frhtylcn.pythonsnippets 常用 Python 代码模板
Code Runner formulahendry.code-runner 一键运行选中代码片段(非常方便)
Path Intellisense christian-kohler.path-intellisense 自动补全文件路径
Tabnine AI Autocomplete(可选) TabNine.tabnine-vscode 基于 AI 的智能代码补全

💡 Code Runner 推荐配置:

{
  "code-runner.executorMap": {
    "python": "python -u"
  },
  "code-runner.runInTerminal": true,
  "code-runner.ignoreSelection": false
}

🧭 五、虚拟环境与终端优化插件

插件名称 标识符 功能
Conda ms-toolsai.jupyter(内置)或 ms-python.python 自动识别 Conda 环境,切换虚拟环境更方便
Remote - WSL ms-vscode-remote.remote-wsl 如果你在 WSL 的 Ubuntu 中写 Python,必装
Terminal Manager fabiospampinato.vscode-terminals 多终端标签页管理

💡 提示:你可以在 Ctrl + ``(反引号) 打开内置终端,配置 Git Bash 为默认:

{
  "terminal.integrated.defaultProfile.windows": "Git Bash"
}

🧰 六、进阶推荐(根据用途选)

用途 插件
数据分析 / 科学计算 Jupyter + Python Data Science Tools
Web 开发 Django / Flask Snippets, REST Client
机器学习 TensorBoard, Jupyter Notebook Renderers
区块链 / 密码学实验 Solidity + Python, Hex Editor
文档撰写 Markdown All in One, markdownlint

⚙️ 七、完整推荐 settings.json 示例

{
  "python.defaultInterpreterPath": "C:\\ProgramData\\anaconda3\\python.exe",
  "python.formatting.provider": "black",
  "editor.formatOnSave": true,
  "python.analysis.typeCheckingMode": "basic",
  "python.linting.enabled": true,
  "python.linting.flake8Enabled": true,
  "isort.args": ["--profile", "black"],
  "editor.minimap.enabled": true,
  "editor.wordWrap": "on",
  "files.autoSave": "onFocusChange",
  "workbench.iconTheme": "material-icon-theme",
  "terminal.integrated.defaultProfile.windows": "Git Bash",
  "code-runner.executorMap": {
    "python": "python -u"
  },
  "code-runner.runInTerminal": true
}

🚀 一键安装命令合集

如果你已经配置好 code 命令(可在 VS Code → 命令面板 → Shell Command: Install ‘code’ command in PATH),
可以一键安装所有推荐插件:

code --install-extension ms-python.python
code --install-extension ms-python.vscode-pylance
code --install-extension ms-toolsai.jupyter
code --install-extension ms-python.black-formatter
code --install-extension ms-python.flake8
code --install-extension ms-python.isort
code --install-extension aaron-bond.better-comments
code --install-extension oderwat.indent-rainbow
code --install-extension usernamehw.errorlens
code --install-extension eamodio.gitlens
code --install-extension PKief.material-icon-theme
code --install-extension zhuangtongfa.Material-theme
code --install-extension njpwerner.autodocstring
code --install-extension formulahendry.code-runner
code --install-extension christian-kohler.path-intellisense

文章作者: 0xdadream
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 0xdadream !
评论
  目录