2017-10-17 6 views
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 

__init__biomes.woodsBiome에서 실행하면 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' 

나는 뭔가 빠져 있다는 느낌이 들었습니다. 누군가 올바른 방향으로 나를 가리킬 수 있습니까?

감사합니다.

+0

소리가 순환적인 가져 오기 문제와 유사합니다. – user2357112

+0

이것은 몇 가지 다른 것들 일 수 있습니다. 아나콘다 (Anaconda) 나 캐노피 (Canopy)와 같은 것으로 이것을 실행하고 있습니까? – roganjosh

+0

예. 'animals.py'도'바이오 메스 '를 가져 옵니까? –

답변

0

아직 댓글을 달 수는 없으므로 여기에 설명이 있습니다.

거기 코드에서, 귀하의 클래스가 자기가 없으면 __init__() 을 호출하는 것으로 나타났습니다. 이 코드가 코드에 어떻게 있습니까?

__init__(self)

변경 아무것도 같은 클래스를 호출합니까?

+0

아니요, 제 실수입니다. 그걸 고치고있어. –