Python Forum
[cx_Freeze] CMD Prompt can't find my setup.py, help needed !
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[cx_Freeze] CMD Prompt can't find my setup.py, help needed !
#1
Hey Programmers, Game Developers and Software Envolvers...

I try to convert my .py file (an simple test, called "Test1") into an executable program,
using CX_Freeze for python 3.6... i get python 3.6.2 and i get it installed with pip,
on windows. This is my '.py file' they want to convert to:

Test1.py:
import pygame
import sys
  
screen = pygame.display.set_mode((800,600))
done = False
  
while not done:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
        elif event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                done = True
          
    screen.fill((255,0,255))
    pygame.display.update()
pygame.quit()
sys.exit()
This is my setup file, called setup.py:
from cx_Freeze import setup, Executable

setup(name = "C:\Users\Gebruiker\Desktop\Python\Scripts\Test",
      version = "0.1" ,
      description = "" ,
      executables = [Executable("Test1.py")])
The commands thad i call in the command prompt:

The folder:
cd C:\Users\Gebruiker\Desktop\Python\Scripts\Test
My setup command after the folder path:
python setup.py build
Now the problem is at follow... the command prompt can't find my setup.py...
Whats wrong with cx_Freeze... i don't know whats the problem...

Can anyone help me about what the problem is and what do i bad ?...

Thanks, Jamie.
Reply
#2
>>> s = 'C:\U'
Traceback (most recent call last):
  File "<interactive input>", line 1
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Never use single \ that way in path for Windows,
because of escape character.
Okay:
>>> s = 'C:/U'
>>> s
'C:/U'
>>> s = r'C:\U'
>>> s
'C:\\U'
>>> s = 'C:\\U'
>>> s
'C:\\U' 
Example setup script Cx_Freeze.
#cx_run.py
from cx_Freeze import setup,Executable
import sys
 
# Replaces commandline arg 'build'
#sys.argv.append("build")
 
# If need to include/exclude module/packages
includes = []
excludes = []
packages = []
 
# Console or Win32GUI
base = None
if sys.platform == "win32":
    #base = 'Console'
    base = 'Win32GUI'
 
# Name of file to make ".exe" of
filename = "Test1.py"
setup(
    name = 'Myapp',
    version = '0.1',
    description = 'Cx test',
    options = {'build_exe': {'excludes':excludes,'packages':packages,'includes':includes}},
    executables = [Executable(filename, base=base, icon=None)])
 
#--|  From command line
#python cx_run.py build
There can bye problem with cx_Freeze and Pygame.


Use Pyinstaller, pip install pyinstaller
Test with your code(Python 3.6.2),i use pipenv for virtual environment in this test.
From command line:
pyinstaller --noconsole --onefile Test1.py
In dist folder there will be 1 file Test1.exe.

Edit:
I did a test with cx_Freeze and it did work with your pygame code
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [cx_Freeze] Build .exe they get more .py files, help needed ! JamieVanCadsand 3 6,877 Oct-02-2017, 10:19 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020