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

    Join Date
    Aug 2013
    Posts
    5
    Rep Power
    0

    Unhappy Python program to exe file problem


    hello, im new to programming, but thought id give it a try, you know something new, im using python version 2.6, ive installed py2exe.Ive changed the path in enviroment variables to the python directory.All my python files(.py) are located the same place as where the command prompt looks for it. I wrote a simple program(the comments are just from an earlier thing)(which may be the reason to whats not working):
    ####x = 3
    ####x = x*x
    ####print x
    ##y = raw_input('enter a number: ' )
    ##print y
    ##y = float(raw_input('Enter a number: ' ))
    ##print y

    x = int(raw_input('Enter an integer: '))
    if x%2 == 0:
    print 'Even'
    else:
    print 'Odd'
    if x%3 != 0:
    print 'And not divisible by 3'
    I made a 'setup' file which contains this:

    from distutils.core import setup
    import py2exe

    setup(console=['program.py'])

    I open the command prompt and type "python setup.py py2exe" and get some code,and a 'error compliling ''program'' and a syntax error, does anyone know what the problem is?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    144
    Rep Power
    4
    Originally Posted by clemontine36
    hello, im new to programming, but thought id give it a try, you know something new, im using python version 2.6, ive installed py2exe.Ive changed the path in enviroment variables to the python directory.All my python files(.py) are located the same place as where the command prompt looks for it. I wrote a simple program(the comments are just from an earlier thing)(which may be the reason to whats not working):
    ####x = 3
    ####x = x*x
    ####print x
    ##y = raw_input('enter a number: ' )
    ##print y
    ##y = float(raw_input('Enter a number: ' ))
    ##print y

    x = int(raw_input('Enter an integer: '))
    if x%2 == 0:
    print 'Even'
    else:
    print 'Odd'
    if x%3 != 0:
    print 'And not divisible by 3'
    I made a 'setup' file which contains this:

    from distutils.core import setup
    import py2exe

    setup(console=['program.py'])

    I open the command prompt and type "python setup.py py2exe" and get some code,and a 'error compliling ''program'' and a syntax error, does anyone know what the problem is?
    can you paste the complete output from py2exe here, and use code tags?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    5
    Rep Power
    0
    Originally Posted by admoore
    can you paste the complete output from py2exe here, and use code tags?

    c:\UsersNIALLS>python setup.py py2exe
    c:\python26\lib\site-packages\py2exe\build_exe.py:16: depractionWarning: the sets module is depracted
    import sets
    running py2exe
    **searching for, required modules **
    error: compling 'program.py' failed
    Syntax error: invalid syntax (program.py, line 1)
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    2
    Rep Power
    0

    Re


    Reinstall the set-up. Take your backup before it. Which version you are using?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    5
    Rep Power
    0

    Unhappy


    Originally Posted by haley01
    Reinstall the set-up. Take your backup before it. Which version you are using?
    Im using python 2.6 and py2exe 0.6.9, which i understand are the correct versions to use together, ive tried reinstalling both of them, no such luck and im unsure of what you mean by'take your backup before it'
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    2
    Rep Power
    0
    take your backup before it'
    well it just mean that you may lost all programmes/ codes if you are going to uninstalling it...
    let me concern to my senior for more about your issue
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    144
    Rep Power
    4
    Originally Posted by clemontine36
    Syntax error: invalid syntax (program.py, line 1)
    This should be pretty clear. You have a syntax error in line one of program.py. Does program.py actually run in python without errors? Can you copy and paste line 1 exactly to this forum?
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    5
    Rep Power
    0
    Originally Posted by admoore
    This should be pretty clear. You have a syntax error in line one of program.py. Does program.py actually run in python without errors? Can you copy and paste line 1 exactly to this forum?
    If i run it in IDLE it comes up with syntax error, but if i open idle and then just a 'new window'(which doesnt have all the copyright stuff and writing at the top) then try to run it, it will execute the script with IDLE and work fine
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    144
    Rep Power
    4
    Originally Posted by clemontine36
    If i run it in IDLE it comes up with syntax error, but if i open idle and then just a 'new window'(which doesnt have all the copyright stuff and writing at the top) then try to run it, it will execute the script with IDLE and work fine
    It would be more helpful if you'd just post line 1 of your program. There's clearly a syntax error there.
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    5
    Rep Power
    0
    Originally Posted by admoore
    It would be more helpful if you'd just post line 1 of your program. There's clearly a syntax error there.
    I posted all of it in my original description, its pretty small

IMN logo majestic logo threadwatch logo seochat tools logo