Search code examples
python-3.6cx-freeze

Nothing happens in cmd after cx_Freeze setup.py execution


I want to convert one of my .py files (which uses the module "pygame" and that module uses "pkg_resources", pyinstaller doesn't support "pkg_resources" that's why I tried cx_Freeze) into .exe files with cx_Freeze and if I execute the setup.py for the cx_Freeze module to start converting, the command prompt just shows a blank line and nothing happens.

C:\Users\PATH\ascension_card_game>python setup.py build

C:\Users\PATH\ascension_card_game>

I already tried to use py2exe (which lead to the same result, it may be a problem with how I use cmd/python commands) and pyinstaller and searched if anyone else had the same issue or other .py to .exe modules, but nothing worked. I have also set the path to my python folder in "evironment variables" (see image) and I tried to set the path manually in cmd with "SET PATH=...".

Environment Variable "PATH"

Thats the setup.py:

from cx_Freeze import setup, Executable

setup(name = "Ascension: Card Game",
      version = "0.1",
      description = "A card game",
      executables = [Executable("ascension.py", base=base)])

I expected that it would generate a .exe file in a folder with other stuff, but nothing happend at all. There's also a manual to use cx_Freeze here: https://pythonprogramming.net/converting-python-scripts-exe-executables/

Update

If I use the anaconda prompt to execute the setup.py file with "python setup.py build" it shows me this error:

Traceback (most recent call last):
  File "setup.py", line 18, in <module>
    executables = executables)
  File "C:\Users\Maxim Stanko\Desktop\programming\Python\Games\ascension_card_game\cx_Freeze\dist.py", line 348, in setup
    distutils.core.setup(**attrs)
  File "C:\Users\Maxim Stanko\Miniconda\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Users\Maxim Stanko\Miniconda\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "C:\Users\Maxim Stanko\Miniconda\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\Maxim Stanko\Miniconda\lib\distutils\command\build.py", line 135, in run
    self.run_command(cmd_name)
  File "C:\Users\Maxim Stanko\Miniconda\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\Maxim Stanko\Miniconda\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\Maxim Stanko\Desktop\programming\Python\Games\ascension_card_game\cx_Freeze\dist.py", line 218, in run
    zipExcludePackages = self.zip_exclude_packages)
  File "C:\Users\Maxim Stanko\Desktop\programming\Python\Games\ascension_card_game\cx_Freeze\freezer.py", line 114, in __init__
    for n in self._GetDefaultBinPathExcludes() + binPathExcludes]
  File "C:\Users\Maxim Stanko\Desktop\programming\Python\Games\ascension_card_game\cx_Freeze\freezer.py", line 239, in _GetDefaultBinPathExcludes
    import cx_Freeze.util
ModuleNotFoundError: No module named 'cx_Freeze.util'

It doesn't have the module cx_Freeze.util. Although I tried to reinstall cx_Freeze and python 3.6 it still didn't work.

Thanks for the help


Solution

  • It finally got it: It wasn't a problem of the cmd or my code, I just installed the newest version of python (3.7) and adjusted the environment variables, so that only those for python 3.7 where there. Now it works just fine! Thanks for the help :)