我有两行代码:
import ui.interface.interface
obj = ui.interface.interface.InterfaceCodes()
我在另一个包中有相同的代码并且工作正常。但我得到以下回溯:
Traceback (most recent call last):
File "./main.py", line 31, in <module>
from materials.materials import *
File "/home/mohsen/codes/amlak/amlak/src/materials/materials.py", line
40, in <module>
from ui.interface.interface import *
File "/home/mohsen/codes/amlak/amlak/src/ui/interface/interface.py",
line 32, in <module>
from ui.materialsFrame import *
File "/home/mohsen/codes/amlak/amlak/src/ui/materialsFrame.py", line
24, in <module>
from ui.materialsFindFrame import *
File "/home/mohsen/codes/amlak/amlak/src/ui/materialsFindFrame.py",
line 14, in <module>
from common.objects.objects import *
File "/home/mohsen/codes/amlak/amlak/src/common/objects/objects.py",
line 28, in <module>
obj = ui.interface.interface.InterfaceCodes()
AttributeError: 'module' object has no attribute 'interface'
当我将我的代码更改为:
from ui.interface.interface import *
obj = ui.interface.interface.InterfaceCodes()
我得到:
Traceback (most recent call last):
File "./main.py", line 31, in <module>
from materials.materials import *
File "/home/mohsen/codes/amlak/amlak/src/materials/materials.py", line
40, in <module>
from ui.interface.interface import *
File "/home/mohsen/codes/amlak/amlak/src/ui/interface/interface.py",
line 32, in <module>
from ui.materialsFrame import *
File "/home/mohsen/codes/amlak/amlak/src/ui/materialsFrame.py", line
24, in <module>
from ui.materialsFindFrame import *
File "/home/mohsen/codes/amlak/amlak/src/ui/materialsFindFrame.py",
line 14, in <module>
from common.objects.objects import *
File "/home/mohsen/codes/amlak/amlak/src/common/objects/objects.py",
line 28, in <module>
Obj = ui.interface.interface.InterfaceCodes()
NameError: name 'ui' is not defined
另外,如果我删除“ui.interface.interface”,我会得到:
Traceback (most recent call last):
File "./main.py", line 31, in <module>
from materials.materials import *
File "/home/mohsen/codes/amlak/amlak/src/materials/materials.py", line
40, in <module>
from ui.interface.interface import *
File "/home/mohsen/codes/amlak/amlak/src/ui/interface/interface.py",
line 32, in <module>
from ui.materialsFrame import *
File "/home/mohsen/codes/amlak/amlak/src/ui/materialsFrame.py", line
24, in <module>
from ui.materialsFindFrame import *
File "/home/mohsen/codes/amlak/amlak/src/ui/materialsFindFrame.py",
line 14, in <module>
from common.objects.objects import *
File "/home/mohsen/codes/amlak/amlak/src/common/objects/objects.py",
line 28, in <module>
Obj = InterfaceCodes()
NameError: name 'InterfaceCodes' is not defined
我的问题是,我真的不知道该怎么做......!