【问题标题】:Why can't VSCode Python linter resolve import of file in the same directory?为什么VSCode Python linter无法解析同一目录中文件的导入?
【发布时间】:2020-07-07 13:07:41
【问题描述】:

采用以下文件夹结构。

sidebar-update
    __init__.py
    index.py
    results.py

当使用语句从results.py 导入index.py 中的给定函数时

from results import getResultsTable

VSCode 产生以下 linting 问题。

unresolved import 'results'Python(unresolved-import)

我将此作为 linter 仅搜索已安装的模块并忽略本地文件。如何添加此功能以使其识别有效的导入语句?

【问题讨论】:

    标签: python visual-studio-code pylint vscode-python


    【解决方案1】:

    通过启用 jedi 并禁用 Visual Studio IntelliCode for Python 来修复它。显然这是语言服务器的问题。

    【讨论】:

    • 我没有安装 Visual Studio IntelliCode,但遇到了同样的问题。禁用 Pylance 对我有用,让 MS Python IntelliSense 扩展保持启用状态。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-02
    • 2021-08-01
    • 2023-01-01
    • 1970-01-01
    • 2018-03-11
    • 1970-01-01
    • 2020-02-03
    相关资源
    最近更新 更多