1
我有文件:AttributeError的:模块 '...' 有没有属性 '...'
biomes.py
import animals
...
class woodsBiome(baseBiome):
# I do stuff
def __init__(self):
self.animals = animals.generateAnimals(5)
animals.py
def generateAnimals(quantity):
# I do stuff
当我在biomes.woodsBiome
上运行__init__
时,它在animals.generateAnimals(5)
上失败。它给出:
Traceback (most recent call last):
File "game.py", line 10, in <module>
import animals
File "/path/to/files/animals.py", line 4, in <module>
from game import die
File "/path/to/files/game.py", line 22, in <module>
areaMap = biomes.generateMap(xMax, yMax)
File "/path/to/files/biomes.py", line 85, in generateMap
biomeList = [woodsBiome(), desertBiome(), fieldBiome()]
File "path/to/files/biomes.py", line 41, in __init__
self.animals = animals.generateAnimals(5)
AttributeError: module 'animals' has no attribute 'generateAnimals'
我有一种感觉,有什么明显的我失踪了。有人能指出我正确的方向吗?
谢谢。
听起来像一个循环进口问题。 – user2357112
这可能是一些不同的事情。你是用Anaconda还是Canopy来运行它? – roganjosh
是的。 'animals.py'还会导入'生物群落'吗? –