سؤال

I'm extremely new to coding in general, and decided to start with Python. I've got some of the basics down, but I always feel like I learn better by just doing things.

I'm using GUI2EXE to help me turn my simple script (asks your name and age, then tells you how old you are in days, hours, minutes, and seconds) into an EXE. When I compile into an EXE (using py2exe), I get this error:

Traceback (most recent call last):
  File "Age.py", line 2, in <module>
EOFError: EOF when reading a line

From previous research, I changed the setup.py to use "console" instead of "window", but ran into the same issue.

Here is my code:

print("Let's see how long you have lived in days, minutes, and seconds!")
name = input("name: ")

print("Now enter your age!")
age = int(input("age: "))

days = age * 365
minutes = age * 525948
seconds = age * 31556926

print(name, "has been alive for", days, "days", minutes, "minutes and", seconds, "seconds! Wow!")

Any suggestions would be greatly appreciated!

P.S. I have both versions 2.7 and 3.3 of Python, but I am focusing on 2.7 for this and most learning.

هل كانت مفيدة؟

المحلول

  1. download pyinstaller from http://www.pyinstaller.org/ (the zip version)
  2. extract it to C:\ , you should now have a path like C:\pyinstaller-2.1\<bunchafiles>
  3. go to your source folder where you normally run your program
  4. hold SHIFT + RIGHTCLICK select "open command window here"
  5. you should now be at a command prompt C:\path\to\code> _
  6. type: python C:\pyinstaller-2.1\pyinstaller.py --onefile --console Age.py
  7. run exe that is gernerated ...

it will only work with 2x I think ...

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top