我的项目结构如下
Project\
Core\
__init__.py (empty)
indicators.py
platform_core.py (which imports indicators)
Tests\
test.py (import Core here)
在test.py我有
import sys
sys.path.append(sys.path[0] + "/..")
import Core.platform_core
如果我import Core.platform_core
并运行test.py,则会收到以下错误消息
ModuleNotFoundError: No module named 'indicators'
如果我import Core
不会发生这种情况。我也尝试过
import Core.indicators
import Core.platform_core
但出现相同的错误。
我的问题是,是否可以在不导入整个子模块的情况下相对导入文件,从而在同一子模块中导入另一个文件?
编辑:
在platform_corer.py中,导入指标的代码是
from indicators import SMA