Python 扩展 (由 Microsoft 提供)
Jupyter 扩展
Pylance (Python 语言服务器)
Data Wrangler (Microsoft 提供)
{
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.provider": "black",
"python.languageServer": "Pylance",
"jupyter.askForKernelRestart": false,
"jupyter.sendSelectionToInteractiveWindow": true,
"editor.renderWhitespace": "selection",
"editor.rulers": [88],
"python.analysis.typeCheckingMode": "basic",
"files.autoSave": "afterDelay",
"python.testing.pytestEnabled": true
}
创建专用数据科学环境:
conda create -n datascience python=3.9 pandas numpy scikit-learn matplotlib jupyter
在 VS Code 中选择正确的 Python 解释器 (Ctrl+Shift+P → "Python: Select Interpreter")
启用硬件加速渲染:
{
"editor.hardwareAcceleration": "on",
"terminal.integrated.gpuAcceleration": "on"
}
对于大型数据集,考虑禁用某些功能:
{
"python.analysis.diagnosticMode": "workspace",
"python.analysis.useLibraryCodeForTypes": false
}
安装交互式可视化扩展:
配置 Jupyter 以在 VS Code 中显示内联图表:
{
"jupyter.enablePlotViewer": true,
"jupyter.plotting.savePlotDir": "~/vscode_plots"
}
为 Python 脚本设置 launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true
}
]
}
对于 Jupyter Notebooks,可以直接使用内置的调试功能
Ctrl+Shift+P
: 打开命令面板Ctrl+,
: 打开设置Ctrl+Shift+E
: 资源管理器Ctrl+Shift+X
: 扩展视图Ctrl+Shift+J
: 打开 Jupyter NotebookShift+Enter
: 运行选中的代码单元格这个配置提供了强大的数据科学开发环境,结合了 VS Code 的轻量级特性和专业的数据科学工具链。