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