#43 TCL_LIBRARY env var set at startup


TCL_LIBRARY and TK_LIBRARY env vars are set when I start up PyCmd from a cmd.exe window that does not have them set. this later causes matplotlib to barf. sure, I could set them or unset them in init.py, but they shouldn't be set in the first place, and especially they shouldn't end up pointing to the PyCmd install directory. frankly I just got lucky figuring out that was the problem because the message from matplotlib made me think I needed a separate tcl install, which I don't.

the only place I could find the string "TK_LIBRARY" is in the file _cx_Freezeinit.pyc in the library.zip file.

I'm running PyCmd-20120927-w64.zip from the snapshots on windows 7/64.


  • juntalis

    juntalis - 2012-10-20

    This is unfortunately caused by cxFreeze's default "Console.py" init script. Not really using cxFreeze too often myself, I'm not really sure of a quick way to fix this, other than modifying the default init scripts themselves. Setting a custom init script (as I tried in https://gist.github.com/3922674) doesn't seem to work, since it still imports the Console.py file for whatever reason at startup.

    Anyways, I went ahead and modified the offending code in question, and compiled it with the python DLL included with that release. The source of the changed file can be found at: https://gist.github.com/3922706.

    To fix your particular issue, open up library.zip and replace the cx_Freezeinit.pyc with the one found at:


    I can also upload the entire library.zip file, if that'll make it easier for you.

  • Horea Haitonic

    Horea Haitonic - 2012-10-22

    Thanks for analyzing the issue, juntalis; this sounds like a bug in cxFreeze -- did you try to submit a bug report?

  • zacktherat

    zacktherat - 2012-10-23

    thanks for the first shot, but I downloaded from http://ge.tt/3KTyEsP/v/0 and replaced that file in my library.zip...but it crashed. could it be the file you provided is for 32bit python? as mentioned above, I'm running 64bit pycmd.


  • juntalis

    juntalis - 2012-10-25

    Hm, that's strange. I actually used the DLL from the snapshot itself to do the compilation. Well, if that doesn't work, try the following:

    Remove the cx_Freezeinit.pyc file from the zip package, and then download the following file:


    Place that in the zip archive with the name: cx_Freezeinit.py

    When the python DLL finds no precompiled module, it should use the uncompiled module instead. (At least, that's how it's working on my computer)

    horeah: The only problem is that the TK_LIBRARY and TCL_LIBRARY environment variables actually do serve a purpose in the case of GUI applications relying on TCL. (Though I'm still wondering why they chose to stick it in the Console init scripts) I haven't really cracked open any documentation on cxFreeze, so I'm not even all that confident that I'm specifying the init script. (I only knew about that argument and the behavior of it from browsing the source for a few moments)

  • zacktherat

    zacktherat - 2012-10-25

    that TK_LIBRARY and TCL_LIBRARY serve a purpose for some gui apps is exactly the problem: the way those are set in the init may not agree with what the user's installs require which will certainly cause mysterious behavior, e.g. their tk apps stop working for no apparent reason. I only figured this out when I looked at the env pycmd was running in and noticed those two.

  • zacktherat

    zacktherat - 2012-10-25

    I downloaded https://gist.github.com/3949743, added to the library.zip contents, removed the .pyc, rezipped it, etc. and that does the trick. now when I start up pycmd no more tcl warts in the env.

    thanks! pycmd is just what I've been looking for when running command line stuff on windows...not too much and not too little, juuuuust right :-)

  • Horea Haitonic

    Horea Haitonic - 2012-10-25

    I just added a topic on cx_freeze's discussion list; I am hoping there is a way to disable this strange behavior (even if this means that the python-tcl and python-tk bindings won't work, for example in PyCmd's init scripts).



Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks