I have just installed python 3.9, but it doesn't come with tkinter apparently. When I try
sudo apt install python3.9-tkI get the message
Note, selecting 'python3-tk' instead of 'python3.9-tk'
python3-tk is already the newest version (3.8.10-0ubuntu1~20.04).
0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded.Python 3.8 is the system default. How can I get tkinter for python 3.9?
UPDATES
As suggested by ubfan1, I tried
dpkg-reconfigure python3-tkbut I got the error
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.9/tkinter/__init__.py'I made a tkinter directory and added empty files for each file that dpkg complained about. (Every file in the tkinter directory, so far as I can see.) Then dpkg-reconfigure ran with no errors, so I tried
sudo apt install python3-tkagain, and I got the same message as above, telling me that the newest package was already installed. I was able to import tkinter in python 3.9, by root=tkinter.Tk() failed. On inspection, all the files in /usr/lib/python/ were still empty, so I decided to copy all the scripts from python 3.8. This time, python told me no module named _tkinter. I found a module named
_tkinter.cpython-38-x86_64-linux-gnu.soin /usr/lib/python3.8/lib-dynload and I copied it into /usr/lib/python3.9/lib-dynload replacing the "38" in the name with "39".
This seems to have worked, in the sense that tkinter runs under python 3.9, but I need hardly say that I don't feel entirely comfortable with this. What's going to happen when I upgrade to python 3.10.?
11 Reset to default