0

I'm new to Python and I'm running Python 3.6. Trying to build an executable using cx_freeze and the code below in a file named "setup.py". I put the python script for the program and the icon file in the python main directory folder. When I type "python setup.py build" into the command prompt it says "running build" and then immediately generates a new command prompt. No errors are given but afterward I can't find the exe anywhere. What am I doing wrong? Am I searching for the exe files in the wrong place or is the build failing without giving an error message?

import cx_Freezefrom cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = ["numpy","tkinter"], excludes = [],includes = ["numpy","tkinter"],
    include_files = ["battleship.ico"])

import sys
base = 'Win32GUI' if sys.platform=='win32' else None

executables = [
    Executable('battleship.py', base=base)
]

setup(
    name='Battleship',
    version = '1.0',
    description = 'A PvC Battleship Game',
    options = dict(build_exe = buildOptions),
    executables = executables
)
  • FYI, I see that the first line is incorrect, but replacing the line with "from cx_Freeze import setup, Executable" produces the same result. – SethBorgo Jun 24 '17 at 00:37

1 Answers1

-1

when you use py2exe try this

import sys
try:
    import py2exe
except:
    raw_input('Please install py2exe first...')
    sys.exit(-1)

from distutils.core import setup
import shutil

sys.argv.append('py2exe')

setup(
    options={
        'py2exe': {'bundle_files': 1, 'compressed': True }
    },
    console=[
        {'script': "script.py"}
    ], 
    zipfile=None,
)

Note : remplace "script.py" with your python script and run this script like this

python exe.py