PyInstaller » 이력 » 개정판 2
개정판 1 (이태훈, 2025/01/27 04:27) → 개정판 2/3 (이태훈, 2025/01/27 06:37)
h1. PyInstaller
h3. 1. cmd를 관리자 권한으로 실행
!clipboard-202501271321-jserb.png!
h3. 2. 명령어 입력
<pre>
-- 프로그램 설치
pip install pyinstaller
-- exe파일 만들기
pyinstaller 파일명.py
-- 콘솔창 제거(-w OR --windowed)
pyinstaller -w 파일명.py
-- 실행파일 하나만 생성(-F 또는 –onefile)
pyinstaller -F 파일명.py
</pre>
h3. 3. 리소스가 포함된 exe 파일 생성
[코드 추가]
<pre>
import sys
import os
def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
</pre>
[실행파일 생성 명령어]
<pre>
pyinstaller -w -F -i="파비콘.ico" --add-data="ui파일명.ui;./" --add-data="파비콘.ico;./" 파일명.py
</pre>