VS Code执行Python,出现Exception has occurred: ModuleNotFoundError
错误内容如下。
Exception has occurred: ModuleNotFoundError
No module named 'log_case'
File "log_suite.py", line 12, in <module>
from log_case.common_logger import logger
配置launch.json文件
配置项新增
"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}"}
}
]
}