公開:
2025/04/14
uvでmatplotlibやろうとすると、tclがないって言われる(uvじゃなくてもこういうことはある)。
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
C:/Users/username/AppData/Roaming/uv/python/cpython-3.13.0-windows-x86_64-none/lib/tcl8.6 C:/Users/username/AppData/Roaming/uv/python/lib/tcl8.6 C:/Users/username/AppData/Roaming/uv/lib/tcl8.6 C:/Users/username/AppData/Roaming/uv/python/library C:/Users/username/AppData/Roaming/uv/library C:/Users/username/AppData/Roaming/uv/tcl8.6.12/library C:/Users/username/AppData/Roaming/tcl8.6.12/library
This probably means that Tcl wasn't installed properly.
という感じ。
実際には...uv\python\cpython...-none\tcl\tcl8.6とかにある。
ので、https://github.com/astral-sh/uv/issues/7036を参照して、
from os import environ
from pathlib import Path
from sys import base_prefix
environ["TCL_LIBRARY"] = str(Path(base_prefix) / "tcl" / "tcl8.6")
environ["TK_LIBRARY"] = str(Path(base_prefix) / "tcl" / "tk8.6")
これでいけるはず。