简体   繁体   English

为什么VSCode Python linter 不能解析同目录下文件的导入?

[英]Why can't VSCode Python linter resolve import of file in the same directory?

Take the following folder structure.采用以下文件夹结构。

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

When importing a given function in index.py from results.py with the statement使用语句从results.py导入index.py中的给定 function 时

from results import getResultsTable

VSCode produces the following linting problem. VSCode 产生以下 linting 问题。

unresolved import 'results'Python(unresolved-import)

I take this as the linter searching solely for installed modules and ignoring local files.我将此作为 linter 仅搜索已安装的模块并忽略本地文件。 How can I add this functionality so that it recognizes valid import statements?如何添加此功能以使其识别有效的导入语句?

Fixed it by enabling jedi and disabling Visual Studio IntelliCode for Python.通过为 Python 启用绝地并禁用 Visual Studio IntelliCode 来修复它。 Apparently it was a language server issue.显然这是一个语言服务器问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM