Tkinter - TCL won't run


I’m trying to request input from a user via a Python script that uses the Tkinter/TCL GUI toolkit. When I run it from the Windows 10 PowerShell it works fine. When I try to run it from a platformio-terminal window I get an error. The main part of the error message is Can’t find a usable init.tcl in the following directories: and then it lists a bunch of paths that all end with /tcl8.5 .

I’ve tried installing & removing the following with no change to the error message:

  • Python 2.7
  • Atom.
  • Python 3.6

Here’s the full error message.

Executed : python upload
Returned with code 1
Traceback (most recent call last):
  File "", line 35, in <module>
  File "C:\Python27\Lib\lib-tk\", line 1819, in __init__ = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: Can't find a usable init.tcl in the following directories: 
    C:/Python27/lib/tcl8.5 C:/Users/bobku/.platformio/penv/lib/tcl8.5 C:/Users/bobku/.platformio/lib/tcl8.5 C:/Users/bobku/.platformio/penv/library C:/Users/bobku/.platformio/library C:/Users/bobku/.platformio/tcl8.5.15/library C:/Users/bobku/tcl8.5.15/library

This probably means that Tcl wasn't installed properly.


Here’s what I did to fix this issue

  1. search all init.tcl files for the line “package require -exact Tcl” that has the highest 8.5.x number
  2. copy it into the first directory listed in the error messages
  3. set the environmental variables TCLLIBPATH and TCL_LIBRARY to the directory where I found the init.tcl file
  4. reboot


What worked for me was the following:

  1. Copy the folder tcl8.5 from C:/Python27/tcl
  2. Paste it to the C:/Python27/lib/ directory.
  3. Copy the folder tk8.5 from C:/Python27/tcl
  4. Paste it to the newly created C:/Python27/lib/tcl8.5 directory.

tcl8.5 and tk8.5 have their own directory (C:/Python27/tcl), but for some reason PlatformIO doesn’t look there.