0

I made a tkinter application in windows and now I want to make an executable version of it. multiframe.py contains all the the code of the tkinter application.

But when I try to build it I always get syntax error but I don't get it why. Here is a cmd snapshot. enter image description here

This is how my setup.py looks like:

    import cx_Freeze

    base = None

    if sys.platform == 'Win32':
            base = "Win32GUI"

    executables = [cx_Freeze.Executable("frame.py"), base=base, icon='ds.ico']

    cx_Freeze.setup(
            name="cuQ",
            options = {"build_exe": {"packages":["tkinter"], include_files=["ds.ico"]},
            version= "0.01",
            description = "dasdasd",
            executables = executables
            )
Marci
  • 427
  • 2
  • 9
  • 20
  • 1
    always put error message as text, not screenshot. We can't copy text from screenshot to use it in answer or to search in Google. – furas Dec 06 '17 at 00:36

1 Answers1

2

base and icon are options of cx_Freeze.Executable in your code they're not being passed to it. They need to be in () just like "frame.py" is so use:

executables = cx_Freeze.Executable("frame.py", base=base, icon='ds.ico')

In cx_Freeze.setup(options = ... you're first adding a dictionary key "packages" as part of the value for the dictionary key "build_exe" but then suddenly you're trying to add a list include_files instead of a key while still inside the dictionary that is the part of the value alongside "packages" to "build_exe" key. It's hard to describe. Anyway.

Your whole code should look like:

import cx_Freeze, sys

base = None

if sys.platform == 'Win32':
    base = "Win32GUI"

executables = cx_Freeze.Executable("frame.py", base=base, icon='ds.ico')

cx_Freeze.setup(
        name="cYou",
        options = {"build_exe": {"packages":["tkinter"], "include_files":["ds.ico"]}},
        version= "0.01",
        description = "dasdasd",
        executables = executables
        )

Below is what I use for tkinter. I just put my tkinter script something.py next to this script. Then I just respond to it something. Some modifications may need to be done in order to include icon files and such:

from cx_Freeze import setup, Executable
import sys, os

fileName = input("What's the name of the py file to be converted to .exe?\n")
sys.argv.append('build')

os.environ['TCL_LIBRARY'] = r'C:\Users\username\AppData\Local\Programs\Python\Python36\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Users\username\AppData\Local\Programs\Python\Python36\tcl\tk8.6'

base = None
if (sys.platform == "win32"):
    base = "Win32GUI"    # Tells the build script to hide the console.
elif (sys.platform == "win64"):
    base = "Win64GUI"    # Tells the build script to hide the console.



setup(
    name='KutsalAklinNerde?',
    version='0.1',              #Further information about its version
    description='Parse stuff',  #It's description
    executables=[Executable(fileName + ".py", base=base)])
Nae
  • 14,209
  • 7
  • 52
  • 79
  • Thanks for the quick answer! Now I get no syntax error, but this: self.executables = list(executables) TypeError: 'Executable' object is not iterable – Marci Dec 05 '17 at 23:43
  • I'm not really sure what's going on but I build my script for exe conversion using [this video](https://www.youtube.com/watch?v=GSoOwSqTSrs). – Nae Dec 05 '17 at 23:47
  • https://www.youtube.com/watch?v=HosXxXE24hA Mine was this :) Does the one you sent work with tkinter too? – Marci Dec 05 '17 at 23:49
  • Well I've modified it a bit using [this answer and comments](https://stackoverflow.com/a/44433442/7032856) as well. Updated my answer to include what I use. – Nae Dec 05 '17 at 23:52
  • Thanks! One thing: executables variable needs to be a list – Marci Dec 06 '17 at 00:09