+--------+-----------------------------------+
| OS | Ubuntu 12.04 |
+--------+-----------------------------------+
| Python | 2.7, 3.2 and source installed 3.6 |
+--------+-----------------------------------+
Since there are 2 versions of Python 3, anything installed from the repository doesn't work for Python 3.6. The latest version of Python in the repositories is 3.2, so I need source installs or through pip3.6.
After starting python3.6
I tried to import tkinter
, which gave the following error. Even though help('modules')
returned a list of modules which included tkinter.
import tkinter
ModuleNotFoundError: No module named '_tkinter'
I tried doing the same in python3.2
and there were no errors. tkinter._tkinter
gave the location of tkinter library for python3.2
I cd'd into the python3.6
directory which has all library files and indeed it was missing the tkinter.so
object file.
How do I fix the error?
I would like to get tkinter/tkagg working as it seems all the modules/ package are already installed.
After googling some more, I found I need to build python3.6
again, but this time with Tcl/Tk options while running configure. I'd rather not. It takes 1hr approx to install python3.6
from scratch.
Is there some other way where I can tell python3.6
where Tcl/Tk is located?
The problem isn't telling python where tcl/tk is. After messing around with python3.6's source code, and then comparing python3.6 with python3.2, I found out that tkinter calls _tkinter which isn't a python file, it's an .so(shared object) file that python builds during installation via setup.py that uses gcc, that somehow may involve distutils.
The new and more appropriate question is how do I build,
_tkinter.cpython-36m-i386-linux-gnu.so
from tcl/tk?
Note : I do have tcl/tk installed, which I have confirmed using tclsh and wish.
run from terminal:
sudo apt-get install python3.6-tk
or just reinstall completly:
sudo apt-get install python3.6