Search code examples
pythontkintertclcx-freezepython-3.6

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


I tried all the previous available solutions available on Stackoverflow but nothing seems to work at all. I am using 64-bit python and python 3.6.1 by Anaconda.

Here is what I receive as an error while I run my exe:

Traceback (most recent call last):

File "C:\Users\Asgard\Anaconda3\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run
    module.run()
  File "C:\Users\Asgard\Anaconda3\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run
    exec(code, m.__dict__)
  File "fbroi.py", line 80, in <module>
    root = Tk(className=" ROI Calculator")
  File "C:\Users\Asgard\Anaconda3\lib\tkinter\__init__.py", line 2017, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: Can't find a usable tk.tcl in the following directories:
    {C:\Users\Asgard\Desktop\ML Proj\EdCrawler\build\exe.win-amd64-3.6\tk} {C:/Users/Asgard/Desktop/ML Proj/EdCrawler/build/exe.win-amd64-3.6/tcl/tk8.6} {C:/Users/Asgard/Desktop/ML Proj/EdCrawler/build/exe.win-amd64-3.6/tk8.6} {C:/Users/Asgard/Desktop/ML Proj/EdCrawler/build/lib/tk8.6} {C:/Users/Asgard/Desktop/ML Proj/EdCrawler/lib/tk8.6} {C:/Users/Asgard/Desktop/ML Proj/EdCrawler/build/library}

Copying tcl8.6 and tk8.6 directories here and there, don't seem to work also.


Solution

  • Ok, It seems that there is no possible solution for me. I had to get rid of cx_Freeze.

    What works for me is this:

    1. Downgrade your python to 3.3 or less because py2exe does not support python 3.6. If you're using conda create a virtual environment. It easily allows installing any python version you want.
    2. Get py2exe on your python environment.
    3. Use py2exe.

    You might find this useful : py2exe usage on Stackoverflow.

    For people using conda : python and conda