在vscode中选择:文件-首选项-设置-扩展-Python-settings.json
向setting.json添加如下代码:
bash
"terminal.integrated.env.osx": {
"PYTHONPATH": "${workspaceFolder}/",
},
"terminal.integrated.env.linux": {
"PYTHONPATH": "${workspaceFolder}/",
},
"terminal.integrated.env.windows": {
"PYTHONPATH": "${workspaceFolder}/",
},
重启vscode即可成功