문제 상황
xgboost를 import한 .py 파일을 pyinstaller로 .exe 로 패키징 할 때 다음과 같은 에러를 출력
xgboost.libpath.XGBoostLibraryNotFound: Cannot find XGBoost Library in the candidate path, did you install compilers and run build.sh in root path?
List of candidates:
C:\...\AppData\Local\Temp\_MEI103562\xgboost\xgboost.dll
C:\...\AppData\Local\Temp\_MEI103562\xgboost\../../lib/xgboost.dll
C:\...\AppData\Local\Temp\_MEI103562\xgboost\./lib/xgboost.dll
C:\...\AppData\Local\Temp\_MEI103562\xgboost\xgboost.dll
C:\...\AppData\Local\Temp\_MEI103562\xgboost\../../windows/x64/Release/xgboost.dll
C:\...\AppData\Local\Temp\_MEI103562\xgboost\./windows/x64/Release/xgboost.dll
해결 방법
다음 글을 참고
https://github.com/dmlc/xgboost/issues/7761#issuecomment-1104619556
Pyinstaller and xgboost · Issue #7761 · dmlc/xgboost
Dear coders, I am trying to launch pyinstaller for my app but it appear the commun error with xgboost and pyinstaller. I am using xgboost version 1.5.2. The error is : import xgboost as xgb File ""...
github.com
1. 파일 추가
[PYTHON PATH]\Lib/site-package/_pyinstaller_hooks_contrib/stdhooks 폴더에 hook-xgboost.py 파일을 생성
""" hook-xgboost.py """
from PyInstaller.utils.hooks import collect_all
datas, binaries, hiddenimports = collect_all("xgboost")
2. 패키징
pyinstaller --collect-all "xgboost" test.py
--add-data "[file_path]; [dir_path]"
--hidden-import "[library]"
'Develop > Python' 카테고리의 다른 글
[Python] Airflow Dag 정보 (Task Context) 전달 (0) | 2025.02.13 |
---|---|
[Python] Window에 pyenv 설치 (0) | 2025.01.02 |
[Python] matplotlib 한글 폰트 전역 설정 (0) | 2024.08.20 |
[Python] 리스트의 원소 곱 - reduce (0) | 2024.01.11 |
[Python] 화면 캡쳐 라이브러리 처리 속도 비교 (0) | 2023.11.02 |