Pylint 对工作相关导入发出错误警告
我有以下文件结构:
├── README.md
├── apps
│ ├── fire_analysis.py
│ └── rois.py
└── streamlit_app.py
文件目录
- slectlit_app.py
from apps import fire_analysis
- apps/fire_analysis.py
from .apps import rois
print(rois.the_object)
- apps/rois.py
the_object = 42 # the object that I want
代码工作正常。但是我得到了e0402:超出顶级软件包(相对范围级别)的尝试相对导入的
来自Pylint的错误警告。
如何解决此警告? 我是在fire_analysis.py
中以错误的方式导入的方式?
I have the following file structure:
├── README.md
├── apps
│ ├── fire_analysis.py
│ └── rois.py
└── streamlit_app.py
File contents
- streamlit_app.py
from apps import fire_analysis
- apps/fire_analysis.py
from .apps import rois
print(rois.the_object)
- apps/rois.py
the_object = 42 # the object that I want
The code works just fine. But I am getting the E0402: Attempted relative import beyond top-level package (relative-beyond-top-level)
error warning from pylint.
How to resolve this warning?
Am I doing the importing the wrong way in the fire_analysis.py
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它可以更改
apps/fire_analysis.py
的导入到告诉Python进行本地搜索。
It works for me to change the import of
apps/fire_analysis.py
totelling python to search locally.