1

I'm trying to figure out how to create a windows executable or a windows installer for my python applications so that I can distribute them with family. For this example I created a checkers game using Python Arcade. I am using Python 3.8.2, and the latest pip install of cx_Freeze in an attempt to create the executable. Here is the setup script:

from cx_Freeze import setup, Executable

sys.argv.append("bdist_msi") # build

exe = Executable(
    script="Checkers.py",
    base="Win32GUI",
    )

includefiles = ["check_icon.ico",
                os.path.join(os.path.dirname(__file__), 'resources', 'audio', "theme.wav"),
                os.path.join(os.path.dirname(__file__), 'resources', 'audio', "grasstheme.wav"),
                os.path.join(os.path.dirname(__file__), 'resources', 'audio', "fighttheme.wav"),
                os.path.join(os.path.dirname(__file__), 'resources', 'audio', "gamepiece.wav"),
                os.path.join(os.path.dirname(__file__), 'resources', 'audio', "gatecoin.wav"),
                os.path.join(os.path.dirname(__file__), 'resources', 'images', "check.png")]

setup(name = "Checkers",
      version = "1.0.0",
      options = {'build_exe': {
          'packages':["arcade", "os", "time"],
          'include_files': includefiles,
          'include_msvcr': True,
          }},
      executables = [exe]
      )

And here is the error message I get when I run it. I followed instructions I found online on using cx_Freeze, but I cannot figure out what has gone wrong.

running bdist_msi
running build
running build_exe
Traceback (most recent call last):
  File "<absolute_path>\Checkers\setup.py", line 19, in <module>
    setup(name = "Checkers",
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\dist.py", line 342, in setup
    distutils.core.setup(**attrs)
  File "<absolute_path>\Python38-32\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "<absolute_path>\Python38-32\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "<absolute_path>\Python38-32\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\windist.py", line 389, in run
    self.run_command('build')
  File "<absolute_path>\Python38-32\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "<absolute_path>\Python38-32\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "<absolute_path>\Python38-32\lib\distutils\command\build.py", line 135, in run
    self.run_command(cmd_name)
  File "<absolute_path>\Python38-32\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "<absolute_path>\Python38-32\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\dist.py", line 217, in run
    freezer.Freeze()
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\freezer.py", line 638, in Freeze
    self.finder = self._GetModuleFinder()
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\freezer.py", line 379, in _GetModuleFinder
    finder.IncludePackage(name)
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 661, in IncludePackage
    module = self._ImportModule(name, deferredImports)
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 308, in _ImportModule
    module = self._InternalImportModule(name,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 409, in _InternalImportModule
    module = self._LoadModule(name, fp, path, info, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 422, in _LoadModule
    return self._LoadPackage(name, path, parent, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 494, in _LoadPackage
    self._LoadModule(name, fp, path, info, deferredImports, parent)
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 473, in _LoadModule
    self._ScanCode(module.code, module, deferredImports)
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 588, in _ScanCode
    importedModule = self._ImportModule(name, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 343, in _ImportModule
    module = self._InternalImportModule(name,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 409, in _InternalImportModule
    module = self._LoadModule(name, fp, path, info, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 473, in _LoadModule
    self._ScanCode(module.code, module, deferredImports)
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 588, in _ScanCode
    importedModule = self._ImportModule(name, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 308, in _ImportModule
    module = self._InternalImportModule(name,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 409, in _InternalImportModule
    module = self._LoadModule(name, fp, path, info, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 422, in _LoadModule
    return self._LoadPackage(name, path, parent, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 494, in _LoadPackage
    self._LoadModule(name, fp, path, info, deferredImports, parent)
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 473, in _LoadModule
    self._ScanCode(module.code, module, deferredImports)
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 588, in _ScanCode
    importedModule = self._ImportModule(name, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 343, in _ImportModule
    module = self._InternalImportModule(name,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 409, in _InternalImportModule
    module = self._LoadModule(name, fp, path, info, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 473, in _LoadModule
    self._ScanCode(module.code, module, deferredImports)
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 588, in _ScanCode
    importedModule = self._ImportModule(name, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 308, in _ImportModule
    module = self._InternalImportModule(name,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 382, in _InternalImportModule
    self._InternalImportModule(parentName, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 409, in _InternalImportModule
    module = self._LoadModule(name, fp, path, info, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 422, in _LoadModule
    return self._LoadPackage(name, path, parent, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 494, in _LoadPackage
    self._LoadModule(name, fp, path, info, deferredImports, parent)
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 473, in _LoadModule
    self._ScanCode(module.code, module, deferredImports)
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 588, in _ScanCode
    importedModule = self._ImportModule(name, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 308, in _ImportModule
    module = self._InternalImportModule(name,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 409, in _InternalImportModule
    module = self._LoadModule(name, fp, path, info, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 473, in _LoadModule
    self._ScanCode(module.code, module, deferredImports)
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 588, in _ScanCode
    importedModule = self._ImportModule(name, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 308, in _ImportModule
    module = self._InternalImportModule(name,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 382, in _InternalImportModule
    self._InternalImportModule(parentName, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 409, in _InternalImportModule
    module = self._LoadModule(name, fp, path, info, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 422, in _LoadModule
    return self._LoadPackage(name, path, parent, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 494, in _LoadPackage
    self._LoadModule(name, fp, path, info, deferredImports, parent)
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 473, in _LoadModule
    self._ScanCode(module.code, module, deferredImports)
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 588, in _ScanCode
    importedModule = self._ImportModule(name, deferredImports,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 343, in _ImportModule
    module = self._InternalImportModule(name,
  File "<absolute_path>\Python38-32\lib\site-packages\cx_Freeze\finder.py", line 397, in _InternalImportModule
    spec = importlib.util.find_spec(name)
  File "<absolute_path>\Python38-32\lib\importlib\util.py", line 94, in find_spec
    parent = __import__(parent_name, fromlist=['__path__'])
  File "<absolute_path>\Python38-32\lib\site-packages\pyglet\libs\darwin\__init__.py", line 36, in <module>
    from .cocoapy import *
  File "<absolute_path>\Python38-32\lib\site-packages\pyglet\libs\darwin\cocoapy\__init__.py", line 32, in <module>
    from .runtime import objc, send_message, send_super
  File "<absolute_path>\Python38-32\lib\site-packages\pyglet\libs\darwin\cocoapy\runtime.py", line 51, in <module>
    objc = cdll.LoadLibrary(util.find_library('objc'))
  File "<absolute_path>\Python38-32\lib\ctypes\__init__.py", line 451, in LoadLibrary
    return self._dlltype(name)
  File "<absolute_path>\Python38-32\lib\ctypes\__init__.py", line 363, in __init__
    if '/' in name or '\\' in name:
TypeError: argument of type 'NoneType' is not iterable
MStrad
  • 23
  • 3

0 Answers0