์๋ ํ์ธ์.
์ค๋์ ํํฐ exeํ์ผ์ ๋ง๋ค๋ฉด์ ๋งํ๋ ์ค๋ฅ ๋ถ๋ถ์ ์ค๋ช ํ๋๋ก ํ๊ฒ ์ต๋๋ค.
pyinstaller๋ pycharm ์ด๋ pip๋ฅผ ํตํด ๊น์์ค๋๋ค.
pyinstaller ์ฌ์ฉ๋ฒ์ ์์ฃผ ๊ฐ๋จํฉ๋๋ค.
pyinstaller [ํ์ผ๋ช ].py
๊ฐ์ฅ ๋ง์ด ์ฌ์ฉํ๋ ์ต์ ์ ์ค๋ช ํ๊ฒ ์ต๋๋ค.
-w : ์ฝ์์ฐฝ์ ๋์ฐ์ง ์์ต๋๋ค.
-F : ํ์ผ ํ๋๋ง ์์ฑํฉ๋๋ค.
pyinstaller -w -F [ํ์ผ๋ช ].py or pyinstaller -noconsole -onefile [ํ์ผ๋ช ].py
๊ธฐ๋ณธ์ ์ธ ์ฌ์ฉ๋ฐฉ๋ฒ์ ๋๋ค. (๋น์ฐํ [ํ์ผ๋ช ].py๊ฐ ์กด์ฌํ๋ ๊ฒฝ๋ก์ pyinstaller๋ฅผ ํด์ฃผ์ด์ผ ํฉ๋๋ค.)
์๋ง ์ด ๊ธ์ ์ฝ์ผ์๋ ๋ถ๋ค์ด ๋ฐฉ๋ฒ์ ์์ง๋ง ์ค๋ฅ๋ก ์ธํด ๊ฒ์ํ์๋ค ๋ณด๋ ์ฌ๊ธฐ๊น์ง ์ค์๊ฒ ๋์๊ฒ ์ฃ ?
๋๋จํ ๊ฒ์ ์๋์ง๋ง ์ ๊ฐ exeํ์ผ์ ๋ง๋ค๋ฉด์ ์ ํ๋ ์ค๋ฅ๋ค์ ํด๊ฒฐํ๋ฉด์ ๋ฐฐ์ ๋ ๊ฒ์ ์ ๋๋ก ํ๊ฒ ์ต๋๋ค.
1. unicodeDecodeError : 'utf-8' codec can't decode byte 0xff
์๋ง utf-8 ์ค๋ฅ๊ฐ ๋ ์ uft-8 decoding์ ํด์ฃผ์ จ์๊ฒ๋๋ค.
#-*- coding:utf-8 -*-
์๋ง ์ด ๋ถ๋ถ์ ์ถ๊ฐํด์ฃผ์ จ๊ฒ ์ง์?
ํ์ง๋ง ์์ฝ๊ฒ๋ uft-8 decoding์ ํด์ฃผ์ด๋ ๋๊ฐ์ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
์ด ์ค๋ฅ๊ฐ ๋จ๋ ์ด์ ๋ ์ฌ๋ฌ๋ถ๋ค์ด ์๋ชป์ ํ ๊ฒ์ด ์๋๋ผ pyinstaller์ ๊ณ ์ง์ ์ธ ๋ฌธ์ ๋ผ๊ณ ํฉ๋๋ค.
https://github.com/pyinstaller/pyinstaller/pull/3895
Specify the utf-8 encoding when opening a text file by bjones1 · Pull Request #3895 · pyinstaller/pyinstaller
This is a fix for #3605, and generally for a number of places in the code where the encoding wasn't specified when opening a file. Since getting this working required more complexity than I exp...
github.com
Python\Lib\site-packages\Pyinstaller\compat.py
์ ๊ฒฝ๋ก์ compat.py๋ฅผ ์ฐพ์ ์ด์ด์ค๋๋ค.
compat.py์ ์ ์๋ ๋ผ์ธ์ ์์ ํด ์ค๋๋ค.
out = out.decode(encoding)
a. ํด๊ฒฐ๋ฐฉ๋ฒ -> out = out.decode(encoding, errors='ignore')
b. ํด๊ฒฐ๋ฐฉ๋ฒ -> out = out.decode(encoding, "replace")
์ ๋ ๊ฒ ์์ ํด์ฃผ์๊ณ ๋ค์ ๋๋ ค๋ณด์๋ฉด ์๋ฌ๋ฅผ ๋ฌด์ํ์ฑ ํด๊ฒฐ๋ฉ๋๋ค.
2. import module error
library๋ฅผ ๋ง์ด ์ฐ๋ค ๋ณด๋ฉด module error๊ฐ ๋ฐ์ํ๊ฒ ๋ฉ๋๋ค.
pyinstaller๋ก ํ์ผ์ ๋ง๋ค๋ฉด์
pycache
build
dist
[ํ์ผ๋ช ].spec
์ด๋ ๊ฒ ์์ฑ๋ ๊ฒ๋๋ค.
[ํ์ผ๋ช ].spec ์ ์ด์ด์ค๋๋ค.
hiddenimports = []
์ ๋ถ๋ถ์ ์ค๋ฅ๊ฐ ๋จ๋ ํจ์๋ฅผ ์ ์ด์ฃผ๋ฉด ๋ฉ๋๋ค.
์๋ฅผ ๋ค์ด
numpy, matplotlib๊ฐ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค๋ฉด,
hiddenimports = ['numpy', 'matplotlib'] ์ด๋ ๊ฒ ์ถ๊ฐํด์ฃผ์๋ฉด ๋ฉ๋๋ค.
pyinstaller๊ฐ ์์ ํ ์คํ ํ๋ก๊ทธ๋จ์ด ์๋๋ผ์ ์ค๋ฅ๊ฐ ๋ง์ด ๋ฐ์ํฉ๋๋ค.
์ ๋ ํ๋ก๊ทธ๋จ ๋ง๋๋ ๊ฒ๋ณด๋ค exeํ์ผ ๋ง๋๋ ๋ถ๋ถ์ ํ์ ๋๋ฌด ๋ง์ด ์ฌ์ฉํด์...
python์ด ์ฝ๋ฉ์ ์๋นํ ๊ฐ๋ ฅํ์ง๋ง, exe๋ ์๋๋ ์๋นํ ์ทจ์ฝํฉ๋๋ค...
ํ์ง๋ง ๋ฐ์ดํฐ์ฒ๋ฆฌ๋, ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ด ๋๋ฌด ๋งค๋ ฅ์ ์ด๋ผ์...
pyinstaller ๊ธ์ ๋ง์น๋๋ก ํ๊ฒ ์ต๋๋ค.
์ ์ง pyinstaller๋ ์๋ง ๊ณ์ํด์ ์๋ก์ด ์ค๋ฅ๊ฐ ๋ฐ์ํด์ ๊ธ์ ๋ง์น ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค ใ