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'還會導入'生物羣落'嗎? –