I am brushing up on my python and as a a part of that I wanted to relearn tkinter. I am running into an issue where whenever I try to run the code through vscode it wont let me and it gives me a module not found error. I know that it is not an issue with my code since when I use a separate terminal it runs fine. I would deal with this but my terminal is constantly closing with no apparent reason. If I try to install tkinter on vscodes terminal it says that the module doesn’t exist
To install it I ran: pip install python3-tkinter
I got the errors: ERROR: Could not find a version that satisfies the requirement python3-tkinter (from versions: none)
ERROR: No matching distribution found for python3-tkinter
I am running fedora 40 and I am using the interpreter that vscode says is recommended which is python 3.11.9 64-bit in /bin/python3
2
Answers
In the python installation screen, you can select tcl/tk in the optional features, which will install the corresponding version of
tkinter
for you.tkinter
cannot be installed bypip
. You could use commandsudo dnf install python3-tkinter
in Fedora.To fix Tkinter issues on Fedora, use
sudo dnf install python3-tkinter
instead of pip. Also, in VSCode, select the correct Python interpreter via the Command Palette (Ctrl+Shift+P
) and Python: Select Interpreter.