2014-07-05 7 views
-1

내 코드 가져올 때 :파이썬 AttributeError/ImportError를 같은 폴더에서

from fin.py import * 
from setup.py import * 

내 오류 :

Traceback (most recent call last): 
    File "<frozen importlib._bootstrap>", line 1519, in _find_and_load_unlocked 
AttributeError: 'module' object has no attribute '__path__' 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "C:\Users\name\Documents\Programming\snake.py", line 4, in <module> 
    from fin.py import * 
ImportError: No module named 'fin.py'; fin is not a package 

내가 같은 폴더에서 파일을 평 수입하고 있습니다. 모든 것이 작동해야하지만 이것은 나타납니다!

편집 : 해결! (끝에서 .py를 제거하고, 전에 시도 했었지만 내 코드의 오타 때문에 NameError가 발생했습니다.)

답변

2

가져올 때 파일의 끝에 .py를 생략 할 수 있습니다 . 당신이 찾고있는 것은 :

from fin import * 
from setup import * 
+0

setup.py는 같은 폴더에 있습니까? 그것은 fin.py 벌금 수입 것 같습니다 - 그것으로 가져 오기의 설치를 전달합니다. 방금 간단한 인쇄 문을 시도하고 내 컴퓨터에서 작동하도록했습니다. 오류에 대해 좀 더 자세히 설명해 주시겠습니까? (snake.py 파일에 의해 호출 된 것처럼) – Jordan

+0

바보 같이 - 해결되었습니다! 감사. 전체 오류를 항상 복사하십시오. 나는 단지 같은 이름의 함수를 잘못 입력했다. – user3808430

+0

굉장! 즐거운 프로그래밍! :) – Jordan