KeyError: ‘TCL_Library’ when I use cx_Freeze

You can work around this error by setting the environment variables manually:

set TCL_LIBRARY=C:\Program Files\Python35-32\tcl\tcl8.6
set TK_LIBRARY=C:\Program Files\Python35-32\tcl\tk8.6

You can also do that in the setup.py script:

os.environ['TCL_LIBRARY'] = r'C:\Program Files\Python35-32\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Program Files\Python35-32\tcl\tk8.6'

setup([..])

But I found that actually running the program doesn’t work. On the cx_freeze mailinglist it was mentioned:

I have looked into it already and no, it is not just a simple recompile —
or it would have been done already! 🙂

It is in progress and it looks like it will take a bit of effort. Some of
the code in place to handle things like extension modules inside packages
is falling over — and that may be better solved by dropping that code and
forcing the package outside the zip file (another pull request that needs
to be absorbed). I should have some time next week and the week following
to look into this further. So all things working out well I should put out
a new version of cx_Freeze before the end of the year.

But perhaps you have more luck … Here’s the bug report.

Leave a Comment