1
votes

Here is my setup.py file for cx_Freeze

import sys
from cx_Freeze import setup, Executable
import os

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

build_exe_options = {"packages":["os"], "includes" : ["tkinter"]}

base = None

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

setup(name='APS West Email Generator',
  version='1.0',
  description='Auto generates Alarm notification emails. And maybe more in the future.',
  options = {"build_exe": build_exe_options},
  executables = [Executable("Tool_EmailGenerator.py", base=base)])

The executable is made with no errors. But when I try to run it I get the following window:

title: cx_Freeze: Python error in main script

contents: Traceback(most recent call last): file "c:\Users\Admin\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freeze\initscripts__startup__.py",line12,in import(name+ "init") file "c:\Users\Admin\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freeze\initscripts\Console.py",line 21, in scriptModule=import(moduleName) File "Tool_EmailGenerator.py", line 2, in File "c:\Users\Admin\AppData\Local\Programs\Python\Python35-32\lib\tkinter__init__.py", line 35, in import_tkinter #if this fails your python may not be configured for Tk ImportError: DLL load failed: The specified module could not be found.

tkinter works when I run the py file pre-cx_Freeze. I've searched the internet and tried various suggestions. nothings worked so far. I'm not sure whats causing this.

1
Now Im getting an error when running 'python setup.py build' from within the correct directory. Now it wont build. Its throwing an ImportError No module named 'tkinter' import error is being raised from within cx_Freeze\finder.py This wasn't happening last night. I cant think of what I could've done to break it.SydDevious
Ok. I completed uninstalled python. ALL of it. deleted from registry keys AND system path. Reinstalled python 3.5 64bit. And im getting the same ImportError: DLL load failed.SydDevious
managed to fix this issue. Instead of doing "includes" : ["tkinter"], I added tkinter to the packages. so: "packages":["os", "tkinter"]. that seemed to work.SydDevious

1 Answers

1
votes

managed to fix this issue. Instead of doing: "includes" : ["tkinter"], I added tkinter to the packages. so: "packages":["os", "tkinter"] that seemed to work