본문 바로가기
파이썬

파이썬 Python 3 앱을 .exe로 어떻게 컴파일합니까?

by º기록 2021. 1. 12.
반응형

Python 앱을 .exe 로 어떻게 변환합니까? tkinter 로 프로그램을 만들었고 다른 사람들이 사용할 수있게 만드는 방법이 궁금했습니다. 저는 Python 3.3을 사용합니다. 조금 검색했지만 아무것도 찾지 못했습니다.

 

해결 방법

 


업데이트 : py2exe가 "찾기"에 문제가있는 타사 모듈을 발견 한 후 kotlet schabowy가 아래에 제안한대로 pyinstaller로 이동했습니다. 둘 다 충분한 문서를 가지고 있으며 명령 줄 매개 변수로 실행할 수있는 .exe를 포함하고 있지만 pyinstaller가 디버깅이나 헤드 스크래칭 없이는 처리 할 수없는 스크립트를 아직 컴파일하지 않았습니다.

다음은 인터프리터의 기본값으로 .exe를 빌드하는 데 사용하는 간단한 편의 함수입니다 (물론 배치 또는 이와 유사한 것도 괜찮습니다).

import subprocess,os
def exe(pyfile,dest="",creator=r"C:\Python34\Scripts\pyinstaller.exe",ico=r"C:\my icons\favicon.ico",noconsole=False):
    insert=""
    if dest: insert+='--distpath ""'.format(dest)
    else: insert+='--distpath "" '.format(os.path.split(pyfile)[0])
    if ico: insert+=' --icon="{}" '.format(ico)
    if noconsole: insert+=' --noconsole '
    runstring='"{creator}" "{pyfile}" {insert} -F'.format(**locals())
    subprocess.check_output(runstring)

 

참조 페이지 https://stackoverflow.com/questions/17907258

 

 

반응형

댓글