I have built a simple soundboard in Python with tkinter and winsound. The soundboard uses some .gif and .wav data files, which I included in the same directory as the python script itself. I wrote the following setup.py file using cx_Freeze:
import sys
from cx_Freeze import Executable, setup
build_exe_options = {'packages':['winsound', 'tkinter'], 'include_files':['battle.gif', 'Battle.wav', 'flag.gif', 'icon.ico', 'ocean.gif', 'Ocean.wav', 'shanty.gif', 'Shanty.wav', 'tavern.gif', 'Tavern.wav']}
base = None
if sys.platform == "win32":
base = 'Win32GUI'
setup(name='Savage Worlds Soundboard',
version='0.1',
description='Soundboard for Pirates of the Spanish Main campaign',
options = {'build.exe':build_exe_options},
executables = [Executable("Savage_Worlds_Soundboard.py", base=base)]
)
When I build the program with python setup.py build in the command prompt, it creates a build folder in the directory normally. However, when I open C:x\build\exe.win-amd64-3.4\Savage_Worlds_Soundboard (the executable file), I get the following error:
cx_Freeze: Python error in main script
---------------------------
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
exec(code, m.__dict__)
File "Savage_Worlds_Soundboard.py", line 5, in <module>
File "C:\Python34\lib\tkinter\__init__.py", line 3421, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "C:\Python34\lib\tkinter\__init__.py", line 3377, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't open "ocean.gif": no such file or directory
Any ideas? Looks to me like cx_Freeze didn't include the additional data files that I specified in setup.py. Maybe I wrote the setup file incorrectly?
You need to move your images to the build directory so the executable can find them. I doubt cx_Freeze will package the images into the executable.