user3063264
user3063264

Reputation: 11

Am having problems using cx_freeze

First of all, the technical stuff: Python : 3.3 cx_freeze : 4.3.2 I have looked through several setups, but accomplished nothing. So far I only get a very quickly closing Python Command Line, and sigh, no exe. The setup.py:

from cx_Freeze import setup, Executable

executables = [
        Executable("Swiss Rounds.py", appendScriptToExe=True, appendScriptToLibrary=False)
]

buildOptions = dict(
        create_shared_zip = False)

setup(
        name = "hello",
        version = "0.1",
        description = "the typical 'Hello, world!' script",
        options = dict(build_exe = buildOptions),
        executables = executables)

Thank you people!

Upvotes: 1

Views: 1693

Answers (1)

justengel
justengel

Reputation: 6320

It looks like you forgot the base for your executable, so cx freeze doesn't know how to make the exe. This is how I structure my setup.py file. This setup will put the exe in a different folder if it is 32 bit.

import os, sys, platform
from cx_Freeze import setup, Executable

targetDir = "./build/"
build_exe_options = {
     "icon": "/assets/images/icon.ico",
     "build_exe": "/build/",
     "packages": [], 
     "includes": ["re", "os", "atexit"],
     "include_files": ["/assets/"],
     "excludes": ["tkinter", "ttk", "socket", "doctest", "pdb", "unittest", "difflib", 
                  "_bz2", "_hashlib", "_lzma", "_socket"],
     "optimize": True,
     "compressed": True,
    }

is32bit = platform.architecture()[0] == '32bit'
if is32bit:
    targetDir = "./buildX86/"
    build_exe_options["build_exe"] = targetDir
# end

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

setup(  name = "MyProgram",
        version = "0.1",
        description = "My program example",
        options = {"build_exe": build_exe_options},
        executables = [ Executable("/myprogram.py", 
                                   targetName="MyProgram.exe",
                                   targetDir=targetDir,
                                   base=base) ]
      )

Run:

python setup.py build

Upvotes: 2

Related Questions