当我试图在另一个目录中导入另一个python类时,出现了这个错误。你知道吗
我的文件夹结构如下所示:
main
/prerequisites
- __init__.py
- BitesizeClusterInfo.py
- ComponentStatus.py
__init__.py
BitesizeDecorator.py
BitesizeImp.py
BitesizeInterface.py
constants.py
execute.py
main.py
我试图从BitesizeClusterInfo.py
导入BitesizeDecorator.py
,但出现以下错误:
Traceback (most recent call last): File "ComponentStatus.py", line 1, in from BitesizeDecorator import BitesizeDecorator ImportError: No module named BitesizeDecorator
我的BitesizeClusterInfo.py
代码片段是这样的:
import os
from BitesizeDecorator import BitesizeDecorator
from execute import Execute
class BitesizeClusterInfo(BitesizeDecorator):
def __init__(self, bitesize):
super(BitesizeClusterInfo, self).__init__(bitesize)
def test(self):
super(BitesizeClusterInfo, self).test()
# add command below
print("\n[1] - Checking cluster info...\n")
# grep the output for ease of reading
cmd = "kubectl cluster-info | grep -E 'master|DNS'"
print(Execute.check_if_exists(cmd))
有人能帮我解决这个问题吗?你知道吗
可以将文件
BitesizeClusterInfo.py
的位置更改为主文件夹,以使行正常工作。你知道吗或使用
如果主文件夹是项目源:
它将是:
相关问题 更多 >
编程相关推荐