#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2005
    Posts
    7
    Rep Power
    0

    Newbie question - EOFError when running exported python program


    Hi, i exported my python module using py2exe (guide was v. helpful), but now when i run the executable, i get an error telling me to check the logfile. i do, and i see this:

    Traceback (most recent call last):
    File "perfectnumbers.py", line 13, in ?
    EOFError: EOF when reading a line

    My program code looks like this-
    Code:
    #Program to find perfect numbers
    
    
    number = 6
    factors = []
    factor = 2
    test = 1
    result = 0
    perfects = []
    count = 1
    perfs = 3
    
    perfs=input("How many perfect numbers? WARNING: Anything larger than 3 will take a long time. Press Ctrl + C to exit. >>>")
    while count <= perfs:
        while factor <= number:
            test = number/factor
            if number%factor == 0:
                factors.append(test)
            factor = factor + 1
        while factors:
            result = result + factors.pop(0)
        if result == number:
            print 'Calculating...'
            perfects.append(number)
            print perfects
            count = count+1
        factor = 2
        test = 1
        result = 0
        number = number+1
    print 'Task Complete'
    Can anybody help?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    11
    em I tried ur code and made it to an .exe without a problem.

    Your just not allowed to enter none into the input()
  4. #3
  5. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    I had no problem running the program on my PC or my Mac. Maybe we're missing something, could you add anything?

    Also you should use the raw_input() function, since input() is unsafe and should never be used... unless for some reason you absolutly have no other choice .

    Take care,

    Mark.
    programming language development: www.netytan.com Hula

  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    11
    whats the difference between input() and raw_input()
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2005
    Posts
    7
    Rep Power
    0
    it could be my computer system - its a network that i don't control because i live at school, and so there are various protection systems in place. It could also be to do with folder structure or something. I'll try again this weekend.
    Could it be to do with whats in the module folder? At the moment i have the folder module inside the python folder, and inside the module folder i have the setup.py module, the actual module shown above, and i think thats it. Could that be part of the problem?
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2005
    Posts
    7
    Rep Power
    0
    i finally got it to work- i changed the setup.py module so that it said
    Code:
    setup(console = [{"script": 'perfectnumbers.py'}])
    instead of
    Code:
    setup(window = [{"script": 'perfectnumbers.py'}])
    and that seemed to make it work. Thanks for all the info!
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    11
    ya that changed the complie thingy to windows if i am not wrong
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2005
    Posts
    7
    Rep Power
    0
    yeah, i think maybe it needed that to work on windows or something. I don't know...
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2005
    Location
    canada, B.C.
    Posts
    12
    Rep Power
    0
    Originally Posted by monkeyman23555
    whats the difference between input() and raw_input()

    i am newbie with python, but i do know that you use input() for when you want a number answer from the user, and you use raw_input() for when you want the user to enter a string.
  18. #10
  19. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    Originally Posted by Dark Uzi
    i am newbie with python, but i do know that you use input() for when you want a number answer from the user, and you use raw_input() for when you want the user to enter a string.
    Not quite. You can use either input() or raw_input() to read in numbers. raw_input() can also read any kind of string, but you can also use input() to read certain types of strings, as we will soon see below. Consider first some code like this:
    x = input("enter something")
    x = raw_input("enter something ")

    Now, if you enter a number like 5, both of them will assign x to 5.

    However, if you enter a string something like this:
    5 + 3
    then raw_input() will read the string and assign x to "5 + 3"
    and input() will evaluate the expression (since it is valid python) and assign x as "8" (which is the result of 5 + 3).

    This means that input() reads and evaluates python expressions, whereas raw_input just reads items as is.
    Try this out:
    Code:
    hello = 55
    x = input("Enter a value ")
    print "x is ", x
    x = raw_input("Enter another value ")
    print "x is ", x
    Now enter "hello" when prompted for input and see what happens .

    Comments on this post

    • CyBerHigh agrees
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo

IMN logo majestic logo threadwatch logo seochat tools logo