pylint无法导入本地模块

发布于 2025-02-13 07:59:09 字数 754 浏览 0 评论 0原文

我的项目具有以下结构:

some_dir/
   __init__.py
   main_prog.py
   support
       __init__.py
       some_file.py

main_prog.py.py中的代码具有以下操作:

from support.some_file import SomeClass

所有功能正常,但Pylint未能导入someClass

需要做什么?我正在终端运行(不使用VSCODE),并且期望“ Pylint”的工作方式与Python 3.8.10相同的工作方式,

请注意,我使用的是 venv ,它具有以下包装:

astroid==2.11.6
dill==0.3.5.1
HiYaPyCo==0.5.0
isort==5.10.1
Jinja2==3.1.2
lazy-object-proxy==1.7.1
MarkupSafe==2.1.1
mccabe==0.7.0
platformdirs==2.5.2
pylint==2.14.3
PyYAML==5.4.1
tomli==2.0.1
tomlkit==0.11.0 
typing_extensions==4.2.0
wrapt==1.14.1

其他答案:其他答案Stackoverflow似乎没有涵盖此简单的情况。

My project has the following structure:

some_dir/
   __init__.py
   main_prog.py
   support
       __init__.py
       some_file.py

The code in main_prog.py has the following:

from support.some_file import SomeClass

All works correctly but pylint fails to import SomeClass.

What needs to be done? I am running in a terminal (not using VSCode) and would expect `pylint' to simply work the same way as Python 3.8.10

Note I am using a venv which has the following packages:

astroid==2.11.6
dill==0.3.5.1
HiYaPyCo==0.5.0
isort==5.10.1
Jinja2==3.1.2
lazy-object-proxy==1.7.1
MarkupSafe==2.1.1
mccabe==0.7.0
platformdirs==2.5.2
pylint==2.14.3
PyYAML==5.4.1
tomli==2.0.1
tomlkit==0.11.0 
typing_extensions==4.2.0
wrapt==1.14.1

Other answers on StackOverflow do not appear to cover this simple scenario.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文