파이썬 - Windows embeddable package 버전에 tkinter 환경 구성
embeddable package 버전인 경우,
파이썬 - "Windows embeddable package"로 개발 환경 구성하는 방법
; https://www.sysnet.pe.kr/2/0/12861
tkinter 모듈이 기본 포함돼 있지 않습니다.
E:\Python3133\embed> python -c "import tkinter"
Traceback (most recent call last):
File "<string>", line 1, in <module>
import tkinter
ModuleNotFoundError: No module named 'tkinter'
게다가 tkinter 모듈은 pypi를 통해서도 배포하고 있지 않는데요,
E:\Python3133\embed> curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
E:\Python3133\embed> python get-pip.py
E:\Python3133\embed> python -m pip install tkinter
E:\Python3133\embed\python.exe: No module named pip
검색해 봐도 딱히 정석적인 방법은 없고, 일단
윈도우 설치 버전을 실행해 "tcl/tk and IDLE" 옵션을 체크하고 설치한 다음,
그것에 포함된 3개의 디렉터리를 복사해야 합니다.
예를 들어 각각의 버전이 다음의 경로에 구성됐다면,
// 설치본 경로
%USERPROFILE%\AppData\Local\Programs\Python\Python313
// Windows embeddable package 경로
E:\Python3133\embed
[tcl 복사]
%USERPROFILE%\AppData\Local\Programs\Python\Python313\tcl ==> E:\Python3133\embed\tcl
[Lib\tkinter 복사]
%USERPROFILE%\AppData\Local\Programs\Python\Python313\Lib\tkinter ==> E:\Python3133\embed\Lib\tkinter
[DLLs 복사]
%USERPROFILE%\AppData\Local\Programs\Python\Python313\DLLs ==> E:\Python3133\embed\DLLs
위와 같이 복사해 오면 됩니다. 그다음, tkinter와 DLLs 디렉터리를 _pth 파일에 등록해 주면 됩니다.
E:\Python3133\embed> type python313._pth
python313.zip
.
Lib
DLLs
# Uncomment to run site.main() automatically
#import site
이후 다시 실행해 보면,
E:\Python3133\embed> python -c "import tkinter; tkinter._test()"
테스트 용도의 "tk" 창이 화면에 뜨는 것을 확인할 수 있습니다.
[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]