Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Intermittently unable to find init.tcl on Windows

Closed / Invalid09ba902e2e37300b14634ea1d750f7e22afeeaf1Created 1 year agoUpdated 269 days ago
Descriptionmarkdown2025-11-26 16:34:01

I've run into a curious problem on Windows where TCL will intermittently be unable to find init.tcl, but with the error "No error", which is especially unhelpful:

>       self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E       _tkinter.TclError: Can't find a usable init.tcl in the following directories: 
E           {C:\builds\m6srz7K6C\0\dev\rvs\rvs\auxd\python\tcl\tcl8.6}
E       
E       C:/builds/m6srz7K6C/0/dev/rvs/rvs/auxd/python/tcl/tcl8.6/init.tcl: couldn't read file "C:/builds/m6srz7K6C/0/dev/rvs/rvs/auxd/python/tcl/tcl8.6/init.tcl": No error
E       couldn't read file "C:/builds/m6srz7K6C/0/dev/rvs/rvs/auxd/python/tcl/tcl8.6/init.tcl": No error
E           while executing
E       "source C:/builds/m6srz7K6C/0/dev/rvs/rvs/auxd/python/tcl/tcl8.6/init.tcl"
E           ("uplevel" body line 1)
E           invoked from within
E       "uplevel #0 [list source $tclfile]"
E       
E       
E       This probably means that Tcl wasn't installed properly.

So far this only happens on our CI build jobs on Windows (Server 2022, docker-windows & gitlab-runner), and only in maybe 1 in every 50 builds. I've had no luck in reproducing the issue locally. Defender is disabled within on the build machines (though I still wouldn't expect 'No error' for that).

As the error comes from TCL itself and there's no multithreading involved as far as I'm aware (tests run via pytest) so I don't think it's anything directly to do with python/tkinter - there shouldn't even be any other processes running tcl at the same time, all entirely sequential.

The relevant bit of source code that's running is:

from tkinter import Tcl, TclError
def run_tcl(filename: str, tcl_code: str) -> str:
    tcl = Tcl()
    try:
        return tcl.eval(tcl_code)
    except TclError as e:
        print(f"Error in Tcl code: {e}", filename)

This has apparently been seen in the wild in a number of places, but mostly in the context of matplotlib, where the solution seems to be switching to a different backend (Agg) that doesn't use tkinter. Obviously this isn't viable for me as I'm running TCL code directly.

  • https://stackoverflow.com/questions/71443540/intermittent-pytest-failures-complaining-about-missing-tcl-files-even-though-the
  • https://github.com/actions/setup-python/issues/1102
  • https://github.com/microsoft/azure-pipelines-tasks/issues/16426
  • https://github.com/orgs/community/discussions/26434
  • https://github.com/matplotlib/matplotlib/issues/29119

For reference, I've seen it when running via pytest 8.4.2 on CPython 3.13.9 (with a build from https://github.com/astral-sh/python-build-standalone), which has (a threaded build of) TCL 8.6.12, but has been seen on 3.12.10 as well (and judging by the other links, plenty of other versions too)

I've had a good search of this bug tracker and the mailing list and haven't found anything particularly relevant. I realise this is a bit of a brain dump and there isn't a huge amount to go on, but I've not got a lot! I don't have any real experience with TCL/TK, so if there's anything more I can turn on to debug this further (environment variables, etc) it would be greatly appreciated!

jan.nijtmanswiki2026-03-09 07:50:30

It looks like this was a problem in tkinter, fixed by this pull-request.

So, closing as Invalid (meaning: not a bug in Tcl but somewhere else)

Log in (anonymous is fine) to add a comment.