Frustration trying to create GUI for python script

淺唱寂寞╮ 提交于 2019-12-13 16:14:58

问题


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:


  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 ...



来源:https://stackoverflow.com/questions/22259333/frustration-trying-to-create-gui-for-python-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!