Python 3, Tkinter & Windows 10

posted in: Python, Software | 0

Python 2.7.12, 3.4 and 3.5 are installed on my Windows 10 computer. Running a test of tkinter in 2.7 works, but the test in either version of Python 3 throws errors:

in Python run import tkinter;tkinter._test()

_tkinter.TclError: Can't find a usable init.tcl in the following directories:
_tkinter.TclError: Can't find a usable tk.tcl in the following directories:

Searching on the errors, there were several references environment variables TK_LIBRARY and TCL_LIBRARY,

set TCL_LIBRARY=C:\Python3\tcl\tcl8.6
set TK_LIBRARY=C:\Python3\tcl\tk8.6

The solution most often found was to copy the contents of the Python3/tcl/ folder to the Python3/Lib folder, but that seems to pollute the Lib folder.

My solution is to create symbolic links in the Lib folder:
as administrator open a console window:

mklink /J c:\Python3\Lib\tcl8.6 c:\Python3\tcl\tcl8.6
mklink /J c:\Python3\Lib\tk8.6 c:\Python3\tcl\tk8.6

So far, this has worked. There are many other folders in the TCL directory, so additional links may be needed.