Today I wanted to start working with Tkinter, but I have some problems.
Python 3.2 (r32:88445, Mar 28 2011, 04:14:07)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from tkinter import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.2/tkinter/__init__.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
So how can I configure my Python 3.2 to work with Tkinter?
Under Arch/Manjaro just install the package
tk
:I encountered this issue on python 2.7.9.
To fix it, I installed tk and tcl, and then rebuild python code and reinstall, and during configure, I set the path for tk and tcl explicitly, by:
Also, a whole article for python install process: Building Python from Source
To get this to work with
pyenv
on Ubuntu 16.04, I had to:Then install the version of Python I wanted:
Then I could import tkinter just fine:
Had the same issue on Fedora with Python 2.7. Turns out some extra packages are required:
After installing the packages, this hello-world example seems to be working fine on Python 2.7:
And through X11 forwarding, it looks like this:
Note that in Python 3, the module name is lowercase, and other packages are probably required...
According to http://wiki.python.org/moin/TkInter :