I recently met a problem while installing the newest python3.X.
Installed it using the Python-3.4.2.tar.xz
package from python.org
After, the intallation I tried importing the tkinter
module but didn't succeed.
The output of import tkinter
was:
>>> import tkinter Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.4/tkinter/__init__.py", line 38, in import _tkinter # If this fails your Python may not be configured for Tk ImportError: No module named '_tkinter'
I also tried following solutions:
but none of them helped.
While trying these solutions, if noticed that the error says:
import _tkinter # If this fails your Python may not be configured for Tk
then i googled about it and found this.
Reading the Checking your Tkinter support section, the Step 1
failed and was stuck in this line
If you install Tcl/Tk in the default locations, simply rerunning "make" should build the _tkinter extension.
Regarding above line, my question is:
Where to find a make file to run a make
command on ?
And, how do I configure the tkinter
so that Python3.4.2 accepts it ?
EDIT:
I forgot to mention but import tkinter
do works for the default installation (Python-3.4.0) of the Python in Ubuntu 14.04.1
Best Answer
In order to build python3.4.2 from source with the
_tkinter
module you need to install the following build dependency:Then all you have to do is running
make
again to add_tkinter
support as thesetup.py
file will automatically detect the tk/tcl headers and create the module:Now you can import tkinter in python3.4.2:
Original answer:
Unless you really need python3.4.2, I would just use the default python3 version on 14.04 (3.4.0)
Then all you have to do is installaling the following packages:
And start the python interpreter this way:
Otherwise you'll always get the version that you installed in
/usr/local
(3.4.2).Importing tk in python3 should work now: