[pyinstaller] pyinstaller 사용법 및 오류해결
2021.07.14 기준 작성된 글입니다.
PyInstaller를 이용하면 파이썬과 PyQt5로 제작한 GUI 코드를 실행파일 (exe)로 만들어서 파이썬이 설치되어 있지 않은 PC에서도 프로그램을 실행할 수 있도록 해줍니다. (PyInstaller 홈페이지)
2022-12-09 내용이 추가된 글을 확인해주세요!
https://dohyeon.tistory.com/57
[ubuntu18.04] pyinstaller 사용법 및 문제해결
오늘은 pyinstaller를 사용해 여러개의 모듈이 묶인 python code를 deploy하는 방법을 정리하려 한다. 리눅스는 윈도우10과 달리 file_name.spec 라는 파일이 생성되지 않는다. 따라서 하나하나 라이브러리
dohyeon.tistory.com
1. Pyinstaller 설치
2. 실행파일(exe)로 만들고자 하는 .py 파일이 있는 디렉토리로 이동
3. exe 파일 생성
4. 에러 발생
AttributeError: Module 'PyQt5' has no attribute '__version__' 에러 발생하였다.
이는 pyinstaller 의 버전이 정확하지 않은 경우가 오류의 원인일 가능성이 높다.
pyinstaller 를 설치할떄 pip install Pyinstaller , sudo apt-get install python-Pyinstaller 와 같이 설치했다면
pyinstaller 는 python 2.x 의 버전을 사용하게 된다.
PyQt5 는 python3 을 기준으로 작성되므로 기존 pyinstaller를 삭제하고
pip3 , python3을 이용해 설치해서 사용하자.
pip3 install Pyinstaller (윈도우)
sudo apt-get python3-Pyinstaller (리눅스)