I am trying to import Tkinter
. However, I get an error stating that Tkinter
has not been installed:
ImportError: No module named _tkinter, please install the python-tk package
I could probably install it using synaptic manager (can I?), however, I would have to install it on every machine I program on. Would it be possible to add the Tkinter library into my workspace and reference it from there?
It is not very easy to install Tkinter locally to use with system-provided Python. You may build it from sources, but this is usually not the best idea with a binary package-based distro you're apparently running.
It's safer to apt-get install python-tk
on your machine(s). (Works on Debian-derived distributions like for Ubuntu; refer to your package manager and package list on other distributions.)
Actually, you just need to use the following to install the tkinter for python3:
sudo apt-get install python3-tk
In addition, for Fedora users, use the following command:
sudo dnf install python3-tkinter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With