I'm struggling to get tkinter working with Python 3.13.0 myself on Linux Mint 22.
Tkinter is working fine with Python 3.12.3 (default from the Synaptic package manager).
I followed the instructions at How to install Python 3.13.0 from source.
$ python3.13
Python 3.13.0 (main, Oct 25 2024, 20:06:35) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
Traceback (most recent call last):
File "<python-input-0>", line 1, in <module>
import tkinter
File "/usr/local/lib/python3.13/tkinter/__init__.py", line 38, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named '_tkinter'
The main reason I'm doing this is because 3.13.0 has a problem on Windows 3.13.0 tkinter versus venv in windows 10, and I wanted to test it on Linux.
There is a really informative post here: Why does tkinter (or turtle) seem to be missing or broken? Shouldn't it be part of the standard library? by Karl Knechtel, which I thought you might like to see.
Another command I have come across that might help is sudo apt-get install python3.13-tk. This package is not available in the LM repository, but I'll add the Ubuntu PPA and try it later. The LM repository has a python3-tk package, but it has not yet been updated for Python 3.13.0.
There's also a nice video at How to install the latest Python version ( Python3.13 ) on Ubuntu 24.04
No guarantees, I'm just making suggestions at this stage.
In the bullseye raspberry pi repository:
Regarding Question 1:
Question 1: Why is there available both tk-dev and tk8.6-dev? Are both v. 8.6?
Both tk-dev and tk8.6-dev are version 8.6. It seems that tk8.6-dev is a later version, unless I'm reading that wrong?
tk-dev/oldstable 8.6.11+1 arm64
Toolkit for Tcl and X11 (default version) - development files
tk8.6-dev/oldstable 8.6.11-2 arm64
Tk toolkit for Tcl and X11 v8.6 - development files
More helpful details are documented at
https://tracker.debian.org/pkg/tk8.6
verifying that version 8.6.11-2 is indeed stable, even though not the very latest stable version (which is 8.6.13-2).
And this from
https://www.tcl.tk/software/tcltk/8.6.html
-----------------------
Latest Release: Tcl/Tk 8.6.15 (Sep 13, 2024)
First released in 2012, Tcl/Tk 8.6.* is the current supported series of releases.
-----------------------
So, 8.6.15-1 is latest but undergoing testing and still considered unstable.
Therefore, I will not use the tk-dev, but instead will get the tk8.6-dev and tcl8.6-dev from the default pi bullseye repository, before building any future python 3.12.5 or greater. In case I find it helpful to ask the raspberry pi folks for further support, I am sticking with their repository versions of these libraries rather than getting the absolute latest from www.tcl.tk. I may change my position on this after some testing and further research.
edit - see also comment @acw1668 thank you for steering me to looking into what is an apt meta package.
https://installati.one/install-tk-dev-debian-12
then made it clear that it is tk-dev that I should install with apt, which will take care of all the packages I was actually considering that I might need to install for my particular tkinter projects, including tk8.6-dev.
That link detailed all the packages I was thinking I might, and probably should install. Although it did not go into detail of what each contributes to the final functionality, it was enough to conclude that it is the tk-dev metapackage that will be my dependency solution.
Regarding Question 2:
Question 2: Can you detail anything I might be missing in this plan, or anything that I do not need to install before the make altinstall of python 3.13, for ensuring full tkinter 8.6 support in python 3.13?
Question 3: (ammended)
I intend to access and play audio files using the final tkinter project. Does anyone have helpful remarks on needed libraries, before the python 3.12.x or python 3.13.x build, that might be needed to ensure full robust audio support specifically in a tkinter project? I can submit this as a separate question if you think that more appropriate for clarity.
Thank you for your thoughts on these matters.