- 파이썬 script 소스 코드를 *.exe 파일로 변환하는 방법

//-------------------------------------
    - pyinstaller 설치
pip install pyinstaller

    - 실행 파일로 만들기
pyinstaller --onefile hello.py
        - 만들어진 hello.exe 실행에 3초 정도 걸림

    - 생성된 실행파일이 다른 모듈 의존도가 낮음
> dumpbin /dependents hello.exe
    KERNEL32.dll
    ADVAPI32.dll


//-------------------------------------
pi2exe
http://www.py2exe.org/
https://github.com/py2exe/py2exe


    - py2exe 설치
pip install py2exe


    - 스크립트 실행 파일로 만들기
https://www.py2exe.org/index.cgi/Tutorial

    - hello.py
print "Hello World!"

    - setup.py 파일 생성

from distutils.core import setup
import py2exe, sys, os

sys.argv.append("py2exe")

setup(
    options={"py2exe": {"bundle_files": 1, "compressed": True}},
    windows=[{"script": "hello.py"}],
    zipfile=None,
)




    - exe 만들기
python setup.py py2exe
        - 만들어진 hello.exe 실행에 2초 정도 걸림


    - 생성된 실행파일이 다른 모듈 의존도가 높음
> dumpbin /dependents hello.exe
    USER32.dll
    SHELL32.dll
    KERNEL32.dll
    VCRUNTIME140.dll
    api-ms-win-crt-string-l1-1-0.dll
    api-ms-win-crt-stdio-l1-1-0.dll
    api-ms-win-crt-convert-l1-1-0.dll
    api-ms-win-crt-environment-l1-1-0.dll
    api-ms-win-crt-heap-l1-1-0.dll
    api-ms-win-crt-utility-l1-1-0.dll
    api-ms-win-crt-runtime-l1-1-0.dll
    api-ms-win-crt-math-l1-1-0.dll
    api-ms-win-crt-locale-l1-1-0.dll


//-------------------------------------

https://github.com/python/cpython

//-------------------------------------
https://stackoverflow.com/questions/5458048/how-can-i-make-a-python-script-standalone-executable-to-run-without-any-dependen

반응형
Posted by codens

댓글을 달아 주세요