raise KeyError (key) from None KeyError: 'TCL_LIB (.Py for Exe)

0

I'm trying to convert a Python script to exe to run on Windows machines, I have the following code in setup.py

import sys
from cx_Freeze import setup, Executable
import subprocess
import socket
import os



base = None
if sys.platform == "win32":
    base = "Win32GUI"

executables = [
        Executable("lista.py", base=base)
]

buildOptions = dict(
        packages = [],
        includes = ["subprocess","socket","os"],
        include_files = [
            os.path.join('C:\Users\Eduardo\AppData\Local\Programs\Python\Python36-32', 'DLLs', 'tk86t.dll'),
            os.path.join('C:\Users\Eduardo\AppData\Local\Programs\Python\Python36-32', 'DLLs', 'tcl86t.dll'),
        ],
        excludes = []
)




os.environ['TCL_LIBRARY'] = "C:\Users\Eduardo\AppData\Local\Programs\Python\Python36-32\tcl\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\Users\Eduardo\AppData\Local\Programs\Python\Python36-32\tcl\tk8.6"

setup(
    name = "ListaConfigs",
    version = "0.0.1",
    description = "Recolhe Informações do Computador",
    options = dict(build_exe = buildOptions),
    executables = executables
 )

Looking for solutions I found the links: Solution 1 and Solution 2 The problem is that both one and the other are error. When I try to run the command:

pyinstaller -F setup.py 

Returns the following error:

 return module_code_object.co_names[co_names_index]
 IndexError: tuple index out of range

The -F builds it with only one executable, without the many other files that are normally generated.

Now when I try with cx_Freeze with the command:

python setup.py build

or     python setup.py bdist_msi

Give the error:

 raise KeyError(key) from None
 KeyError: 'TCL_LIBRARY'

There is no python folder in either Program Files or x86. For some reason it was installed on this path that is in the code.

I do not know what can be done here.

Thank you in advance for your attention.

NOTE: I checked the pyinstaller and it looks like it is not yet compatible with python 3.6 ( Link it say this then you should not use a version prior to that to work

    
asked by anonymous 21.09.2017 / 16:49

1 answer

1

Yes, the Stable version of pyinstaller is only compatible with Python 2.7, 3.3-3.5, Python 3.6 is only supporting in the Development version of pyinstaller, but it is not yet stable software.

You can even risk and download (and manually install) the unstable version:

Since the cx_Freeze error is not defined in the environment variables as TCL_LIBRARY , you can execute them without defining it either directly in the CMD (based on this answer of SOen , I do not know if it works on 3.6):

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

However I think it's more practical to set in setup.py

os.environ['TCL_LIBRARY'] = r'C:\Program Files\Python36-32\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Program Files\Python36-32\tcl\tk8.6'
    
21.09.2017 / 18:50