2012-09-18 1 views
1

싱글 톤을 포함하는 컴파일 된 응용 프로그램을 실행하는 데 문제가 있습니다. .pyw 컴파일 프로세스는 정상적으로 진행되지만 결과 .exe를 실행하려고하면 다음과 같은 오류 로그가 기록됩니다. 메시지는 다음과 같습니다 :싱글 톤을 포함하는 컴파일 된 응용 프로그램을 실행할 때 문제가 발생했습니다.

Traceback (most recent call last): 
    File "main.pyw", line 16, in <module> 
    File "tendo\singleton.pyc", line 20, in __init__ 
AttributeError: 'module' object has no attribute '__file__' 

이 내가 싱글을 전화 했어 방법은 다음과 같습니다

from tendo import singleton 
me = singleton.SingleInstance() 
+1

더 구체적으로 코드를 입력하십시오 – GodMan

+0

어떻게이 앱을 "컴파일"합니까? 'py2exe'? 다른 것? 그것은 .exe 파일에 압축되기 전에 작동합니까? – senderle

+0

@Senderle : py2exe를 사용하여 창을 실행 가능하게 만듭니다. – CoCoMonk

답변

1

tendo의 싱글 모듈 sys.modules['__main__'].__file__makes use 메인 디렉토리를 찾을 수 있습니다. py2exe에서는 존재하지 않기 때문에이 오류가 발생합니다.

this answer으로 해결할 수 있습니다. 텐도/singleton.py에서, 라인 (20)은, 당신은 :

self.lockfile = os.path.normpath(tempfile.gettempdir() + '/' + 
    os.path.splitext(os.path.abspath(sys.modules['__main__'].__file__))[0] \ 
    .replace("/","-").replace(":","").replace("\\","-") + '-%s' % flavor_id +'.lock') 

이 같은 교체 : 저자에 대한 문제로

path_to_script = get_main_dir() #see linkd answer 
self.lockfile = os.path.normpath(tempfile.gettempdir() + '/' + path_to_script 
    .replace("/","-").replace(":","").replace("\\","-") + '-%s' % flavor_id +'.lock') 

신고하기를, 및/또는과 풀 요청을 고치다.

+0

끝내 주셔서 고맙습니다. – CoCoMonk

관련 문제