ModuleNotFoundError:没有名为“StrucPy”的模块 - 内部包

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

从文件夹“Testfiles”运行开发的包“StrucPy”时 - 它显示“找不到模块”。当放置在文件夹“Testfiles”之外时,相同的“testfile1”可以有效地导入“StrucPy”。我尝试了一切,但它不起作用。我应该做什么才能让它发挥作用。

init.py 文件夹包含-“从 StrucPy 导入 RCFA”

这是文件夹排列和位置的屏幕截图。

enter image description here

python-3.x package python-import internals
1个回答
0
投票
我认为导入有问题。您正在尝试导入层次结构中高 1 级的文件。因此,在 testfile1.py 中,不要写

from StrucPy.RCFA import RCF

,而是写 
from ..StrucPy.RCFA import RCF
。希望它会起作用。

© www.soinside.com 2019 - 2024. All rights reserved.