0

I've been unable to figure this issue with cx_Freeze out after a good amount of searching. These questions did not offer solutions that worked:

cx_Freeze Exe Application closes as soon as opens

How can I bundle other files when using cx_freeze?

The files are located in the same directory as rest of the game, everything works fine when I run the game from my code, the only issue is when I try to run it from the .exe file.

When I comment out the code of my game that loads in music/images, and build from that, the game works fine.

import cx_Freeze
import os


os.environ['TCL_LIBRARY'] = "C:\\Users\\Dan\\AppData\\Local\\Programs\\Python\\Python36-32\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\\Users\\Dan\\AppData\\Local\\Programs\\Python\\Python36-32\\tcl\\tk8.6"


includedfiles = ['Background.jpg', 'Background2.jpg', 'bgStream.jpg', 'IntroMus.mp3', 'StreamSong.mp3']
excludes = ['tkinter']

cx_Freeze.setup(
    name="The Woodsman's Tale",
    version='0.1',
    description='TWT Game',
    options={'build.exe': {'excludes': [excludes], "packages": ["pygame"],
                           'included_files': [includedfiles]}},
    executables=[cx_Freeze.Executable("startmenu.py")])
skrx
  • 19,980
  • 5
  • 34
  • 48
SchrodingersStat
  • 291
  • 3
  • 19
  • Try [this solution](https://stackoverflow.com/a/38916822/6220679): `includedfiles = [find_data_file('Background.jpg'), find_data_file('Background2.jpg'), etc.`. – skrx Sep 21 '18 at 21:50
  • `Pygame error: couldn't open 'filename'` usually means the path or file name is incorrect. – skrx Sep 21 '18 at 21:52

1 Answers1

0

The build_exe option to include files is named include_files, not included_files. Try to replace the corresponding lines of your setup script by

options={'build.exe': {'excludes': [excludes], "packages": ["pygame"],
                       'include_files': [includedfiles]}},
jpeg
  • 2,372
  • 4
  • 18
  • 31