FYI - python-build-standalone now builds dynamic Tkinter/Tcl/Tk

Author: geofftCreated Aug 8, 2025Updated Sep 27, 2026
Labelsbug

Hi! In today's release of python-build-standalone we've split out _tkinter, libtcl, and libtk into their own dynamic libraries (astral-sh/python-build-standalone#676). I haven't tested with PyInstaller myself yet but I imagine this is helpful. It looks like the implementation of #9014 is that it will magically work now, but I figured I'd open an issue so you all can explicitly test. Please let me know if something in this setup doesn't work right for you!

You can test it out by making sure you have the latest version of uv and you've upgraded your managed Python installs, or grabbing the 20250808 release from python-build-standalone. See https://github.com/astral-sh/python-build-standalone/issues/129#issuecomment-3169282440 for full instructions.

Details on the implementation, if it's helpful:

  • _tkinter is now a separate extension module and no longer statically linked into bin/python and libpython (so any user code using _tkinter will need to bundle the dynamic library and unpack it at runtime)
  • There are separate libtcl8.6.so and libtk8.6.so (or .dylib) libraries inside our lib directory.
  • On Linux, bin/python3 has a DT_RPATH pointing it at the lib directory, so import _tkinter finds our copies of libtcl and libtk. Users of libpython3.x.so will need to set up rpaths or something on their own. (If it's helpful can add an rpath to libpython3.x.so, or tweak the DT_NEEDED in _tkinter to use $ORIGIN/../../libtcl8.6.so etc. (though that trick would only work for gllibc, not musl).
  • On macOS, lib/python3.x/lib-dynload/_tkinter.cpython-3x-darwin.so has an LC_RPATH pointing at @loader_path/../../, and the install name of libtcl and the LC_LOAD_DYLIB entry in _tkinter is @rpath/libtcl8.6.so.dylib, and the same for libtk. So if you maintain the lib/ directory structure you shouldn't need to fiddle with library paths on your own.
  • libX11 and friends are now statically linked into libtk. At some point I might make these dynamic libraries and/or attempt to look for the system version.