Heesung Yang

[문제 해결] pyinstaller - OSError: Python library not found

현상

pyenv로 구성한 파이썬 가상환경에서 Qt5 파이썬 코드를 pyinstaller 빌드 시 아래와 같은 에러 발생

OSError: Python library not found: libpython3.8m.so, libpython3.8m.so.1.0, libpython3.8.so.1.0, libpython3.8mu.so.1.0
    This would mean your Python installation doesn't come with proper library files.
    This usually happens by missing development package, or unsuitable build parameters of Python installation.

    * On Debian/Ubuntu, you would need to install Python development packages
      * apt-get install python3-dev
      * apt-get install python-dev
    * If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)

원인

pyinstaller를 사용하기 위해선 python 컴파일 시 --enable-shared 옵션을 추가하여 컴파일 해야 함

해결 방안

pyenv 를 이용하여 파이썬 설치 시 shared library 옵션을 활성화하여 설치

~$ env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.8.10

참고