Python

Pyinstaller - 간단한 사용법

sckwon770 2019. 7. 6. 16:39

 

 

 

pyinstaller 는 .py 파일을 .exe 파일로 변환해주는 파이썬 툴임

 

WinXP Win7 Win10 에서 정상 작동하는 것을 테스트했음

 

Setup


1. pip 사용

pip install pyinstaller
pip3 install pyinstaller

2. 홈페이지에서 다운로드 http://www.pyinstaller.org

 

PyInstaller Quickstart — PyInstaller bundles Python applications

PyInstaller freezes (packages) Python applications into stand-alone executables, under Windows, GNU/Linux, Mac OS X, FreeBSD, Solaris and AIX. PyInstaller’s main advantages over similar tools are that PyInstaller works with Python 2.7 and 3.4—3.7, it build

www.pyinstaller.org

 

Usage


- 명령어 (터미널전용)

 

1. 다른 패키지 파일없이 exe 파일만 생성: -F (not -f) / --onefile

pyinstaller sameple.py -F
pyinstaller sameple.py --onefile

2. 실행시 콘솔창제거: -w / --noconsole

pyinstaller sample.py -w
pyinstaller sample.py --noconsole

3. 실행파일의 아이콘 등록: -i=(path) / --icon=(path)

기본 경로는 코드의 경로임. 경로를 변경하고 싶다면, 다음과 같이 경로를 작성해야함.

  1. C:\python file\icon.ico
  2. \icons\icon.ico      -> (code location)\icons\icon.ico
pyinstaller sample.py -i=icon.ico
pyinstaller sample.py --icon=icon.ico

4. 관리자 권한 부여: --uac-admin

-F / --onefile 명령어와 함께 사용 불가

(직접 사용해봤을때, -F 명령어와 함께 사용하지 않아도 작동하지 않았음)

pyinstaller --uac-admin sample.py