pylint的 - 无法导入从其他程序运行的模块

问题描述 投票:0回答:1

我有这样的目录结构:

+Root
  +B
    -module_B.py
    -module_A.py
  -mainprogram.py
  1. mainprogram.py我使用的是存在于somefun()功能module_B.py
  2. module_B.py我使用anotherfun()功能module_A.py

然而,当我使用语句from module_A import anotherfun()module_B.py,当我运行在运行时mainprogram.py它给出No module named module_A错误module_B.py

所以,我在qazxsw POI改变qazxsw POI到qazxsw POI和它运行良好仅供from module_A import anotherfun()module_B.py这虽然对人体无害很讨厌打字的时候给我一个错误。

python visual-studio-code pylint
1个回答
0
投票

你应该尝试添加from B.module_A import anotherfun()文件到根目录导入需要形成“B”目录的内容。例如您Pylint文件应包含;

Visual Studio Code

然后你__init__.py文件可以简单地包括:

__init__.py

这有助于保持从长远看组织一切,如果你增加更多的目录等

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.