Reputation: 145
The Bullseye image's python3.9.2 finds tkinter, but I intend to have other versions of python3, all supporting tkinter.
First python3.12.5 was built from source and tried. The python 3.12.5 seems to work, but it can not find tkinter, although the file is there in the filesystem, where it should be after a python3.12 build.
History.
After reading several online resources, blogs, and then booting up a clean Bullseye on a pi4b...
1- downloaded the gzipped tarball of the python 3.12.5 source from python.org and expanded it.
2- then installed some recommended (necessary?) libraries as recommended by several online resources
pi@raspberrypi:~ $ sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev
build-essential is already the newest version (12.9).
libgdbm-dev is already the newest version (1.19-2).
libffi-dev is already the newest version (3.3-6).
libffi-dev set to manually installed.
libncurses5-dev is already the newest version (6.2+20201114-2+deb11u2).
libnss3-dev is already the newest version (2:3.61-1+deb11u3).
zlib1g-dev is already the newest version (1:1.2.11.dfsg-2+deb11u2).
libssl-dev is already the newest version (1.1.1w-0+deb11u1+rpt1).
The following NEW packages will be installed:
libreadline-dev libsqlite3-dev
Done.
3- Next was the build of python 3.12.5 using a make altinstall, wanting to keep the original image's python3.9.2 intact.
All seemed to be working fine in the python 3.12.5, until importing tkinter. The current project is a tkinter project. But, although tkinter was indeed there on the system, it could not be found when running the python 3.12.5.
After more research, apparently, one must first be sure that the tk-dev library is available on the system, before building any python3 versions. Checking the system, no, tk-dev was not there on the system.
Checking the repository for Bullseye, yes, tk-dev is there for installing. I ran the default Bullseye's python3.9.2. The tkinter for 3.9.2 works.
exit and then run python3.12.5. It does not find the 3.12.5 installed tkinter, even though it is there also after the make install. Binding problem?
Conclusion: Assuming that the packaged python 3.9.2 was built for the Bullseye image, with tk-dev properly available, at that time, when the image was prepared and tested for distribution, then, tk-dev and possibly tcl-dev must first be installed on the system before any other additional python3 build, if those future python3 builds are to be able to find their tkinter file(s). Perhaps the tk-dev ensures proper bindings for tkinter when building a python3 version? And this then leads up to the questions:
When searching the repository, the following resources were found...
tk-dev
tk-doc
tk8.6
tk8.6-dev
tk8.6-doc
tcl
tcl-dev
tcl-doc
tcl8.6
tcl8.6-dev
I would like tkinter version 8.6 since it seems it is still the most up to date.
Question 1: Why is there available both tk-dev and tk8.6-dev? Are both v. 8.6?
I am planning next to do:
sudo apt install tk-dev tk-doc tk8.6-dev tk8.6-doc
sudo apt install tcl-dev tcl-doc tcl8.6 tcl8.6-dev
Deciding today to build python 3.13 instead,
next, do a make altinstall of python 3.13
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?
Thank you.
Upvotes: 1
Views: 731
Reputation: 145
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.
Upvotes: 0
Reputation: 2059
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.
Upvotes: 1