Python .py to .exe using cx_Freeze

Í uses cx_Freeze to build .exe but it won’t run
EOF Error when í try to run the .exe file

Tracebace (most recent call last):
line 12, in <module>
__import__(name + “__init__”)
line 24, in <module>
exec(code, m.__dict__)
File"", line 19, in <module>
File"", line 13, in main
File"", line 6, in getInputs
EOFError: EOF when reading a line

The scrip:
import sys
from cx_Freeze import setup, Executable

base = ‘Console’
if sys.platform == ‘win32’:
base = ‘Win32GUI’

options = {
‘build_exe’: {
‘packages’: [“os”,“sys”,“ctypes”,“win32con”],
‘include_files’: [‘’],
‘include_msvcr’: True,

Sometimes a little fine-tuning is needed

exclude all backends except wx

‘excludes’: [‘gtk’, ‘PyQt4’, ‘PyQt5’, ‘Tkinter’]

executables = [
Executable(‘’, base=base)]

author = ‘Fous’,
description=‘Simple Projectile script’,

The scrip:

from projectile2 import Projectile

def getInputs():
a = input("Enter the launch angle (in degrees): ")
v = input("Enter the initial velocity (in meters/sec): ")
h = input("Enter the initial height (in meters): ")
t = input("Enter the time interval between position calculations: ")
return float(a),float(v),float(h),float(t)

def main():
angle, vel, h0, time = getInputs()
cball = Projectile(angle, vel, h0)
while cball.getY() >= 0:
print ("\nDistance traveled: %0.1f meters." % (cball.getX()))

if __name__ == ‘__main__’: main()

The Script:

Provides a simple class for modeling the flight of projectiles.”""
import os
import sys
from math import pi, sin, cos
class Projectile:
#The below is a __doc__ string; its like a comment which can be
#calling Projectile.__doc__
“”“Simulates the flight of simple projectiles near the earth’s
surface, ignoring wind resistance. Tracking is done in two
dimensions, height (y) and distance (x).

def __init__(self, angle, velocity, height):
“”“Create a projectile with given launch angle, initial
velocity and height.”""
self.xpos = 0.0
self.ypos = height
theta = pi * angle / 180.0
self.xvel = velocity * cos(theta)
self.yvel = velocity * sin(theta)

def update(self, time):
“”“Update the state of this projectile to move it time seconds
farther into its flight”""
self.xpos = self.xpos + time * self.xvel
yvel1 = self.yvel - 9.8 * time
self.ypos = self.ypos + time * (self.yvel + yvel1) / 2.0
self.yvel = yvel1

def getY(self):
“Returns the y position (height) of this projectile.”
return self.ypos

def getX(self):
“Returns the x position (distance) of this projectile.”
return self.xpos

Any help please

You need to post your code in a code block, or point us to a gist or repository, as your post has lost the (very important!) formatting.

Googling “cx_freeze input” gets me some hits which show that others have problems with input() and cx_freeze. input() requires a console window and that could be difficult to get using cx_freeze. E.g. one post mentions that using “base = Win32GUI”, just like you do, hides the console, so no input.

You need to either rework your cx_freeze config so that you get a console, or rework your app to take input via a GUI dialog or something.

1 Like

I had the same issue with converting it to .exe and when i make the base = none instead of Win32GUI it works. 

Is there a way to make it work without having to open up the console?