在使用VScode编程或者Debug时,会遇到本地头文件加载失败等问题。解决方案如下:
在lauch.json中,修改 "env": {}为 "env": {"PYTHONPATH":"${workspaceRoot}"}
如下:
{
// 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}",
"console": "integratedTerminal",
"env": {"PYTHONPATH":"${workspaceRoot}"}
}
]
}

launch.json 在点击debug模式下的红色位置按钮时显示,如上图
解决VScode中Python本地头文件加载失败的问题,通过修改launch.json中的环境变量设置,确保IntelliSense正常工作并提高Debug效率。
1089

被折叠的 条评论
为什么被折叠?



