无法解析 Pylance 导入

时间:2021-07-01 00:09:18

标签: python-3.x visual-studio-code python-import pylance

我在主 python 文件的目录中有一个名为 helper 的模块,但 pylance 警告 Import "helper" could not be resolved 即使 python3 运行完美,如何解决这个问题?
helper 是一个目录

目录结构:

main.py
helper/
└── __init__.py

main.py:

import helper
helper.run()

2 个答案:

答案 0 :(得分:0)

尝试添加

  "python.analysis.extraPaths": ["./helper"]

到您的 .vscode/settings.json 文件,如下所述https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#unresolved-import-warnings

答案 1 :(得分:0)

我不知道为什么,但现在可以了,谢谢您的帮助!