I'm trying to create a standalone exe from a script writen in Python 3.5 using cx_Freeze to be able to run it on computers without Python.
The program itself is just a small calculator with a simple UI using tkinter. Im using Windows 10.
I created a setup script that looks like this.
import sys
from cx_Freeze import setup, Executable
# replaces commandline arg 'build'
sys.argv.append("build")
filename = "Widgets_tmp.py"
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup(
name = "Widgets",
version = "1.0",
# options={"build_exe": {"packages": ["tkinter"]}},
description = "cx_Freeze Tkinter script",
executables = [Executable(filename, base=base)])
This runs without problems until i try to run the exe. Then I get this error:
Traceback (most recent call last):
File "C:\python64\lib\site-packages\cx_freeze\initscripts\Console.py"
line 21, in <module>
exec(code, m.__dict__)
File "Widgets_tmp.py", line 1, in <module>
File "C:\python64\lib\tkinter\__init__.py", line 35, in <module>
import _tkinter#If this fails you Python may not be configured for Tk
ImportError: DLL load failed:
I tried including tkinter manualy in the code commented out in the code and in "includes" instead of "packages" but with the same results.
perhaps i should say that line 1 in Widgets_tmp.py looks like this:
import tkinter as tk
I tried freezing the sample code from the source but get the same error. Both codes work perfect using python.
I also tried using:
options={"build_exe": {"includes": ["tkinter"]}},
but no luck.