Thread: py2exe

Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    58
    Rep Power
    10

    py2exe


    for some reoson whenever i try to convert what happens is-

    >>> python setup.py py2exe
    SyntaxError: invalid syntax
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    58
    Rep Power
    10
    i have made my file and setup. i just cant seem to find out the problem.
    my file is random.py

    import py2exe

    print "hello world"


    and my setup is setup.py

    #setup.py
    from distutils.core import setup
    import py2exe

    setup(console=["random.py"])


    any one have an idea?
  4. #3
  5. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Saddly you may run into some problems down the line if you use random.py as you're filename since this is already the name of a module. Though since you're going to be creating an exe from this it might not mater, still, its not the best idea.

    Ok, so the reason you're getting the SyntaxError is simply this, you need to enter something like...

    C:\> python path/to/setup.py py2exe
    into your system shell (dos) not the Python shell. It should work then, i can't see any problems with your setup file at first glance.

    Also, I dont believe have to import py2exe into the script you want to compile. So simply...

    Code:
    print 'hello world'
    should work fine .

    Hope this helps,

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

  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    58
    Rep Power
    10
    when i try it it says that the colin is an invalid syntax-

    Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> C:\>python python23/files/setup.py py2exe
    File "<stdin>", line 1
    C:\>python python23/files/setup.py py2exe
    ^
    SyntaxError: invalid syntax
    >>> c:\>python python23/files/setup.py py2exe
    File "<stdin>", line 1
    c:\>python python23/files/setup.py py2exe
    ^
    SyntaxError: invalid syntax
    >>>

    i tried it in both command prompt
    and the python command line
  8. #5
  9. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    On Windows the command line uses the \ character and not /.

    c:>python python23\files\setup.py py2exe

    Assuming python is on the search path!

    BTW Mark is correct - you do not need to import py2exe into your target file - only in the setup.py file.

    grim
  10. #6
  11. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Originally Posted by evilbeefcake
    when i try it it says that the colin is an invalid syntax-

    Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> C:\>python python23/files/setup.py py2exe
    File "<stdin>", line 1
    C:\>python python23/files/setup.py py2exe
    ^
    SyntaxError: invalid syntax
    >>> c:\>python python23/files/setup.py py2exe
    File "<stdin>", line 1
    c:\>python python23/files/setup.py py2exe
    ^
    SyntaxError: invalid syntax
    >>>

    i tried it in both command prompt
    and the python command line
    Evil, you need to enter python setup.py py2exe at the command line! Not in the Python shell! To get to the command like click start > run and type command or cmd into the box provided.

    Mark.
    Last edited by netytan; July 27th, 2004 at 06:35 AM.
    programming language development: www.netytan.com Hula

  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    58
    Rep Power
    10
    now it says that the colin has a syntax error when i type it in.
  14. #8
  15. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    Post the error report - not sure what colin is!
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    58
    Rep Power
    10
    a colin is this- : -. Same as above except that instead of c bieng the syntax the colin is.
  18. #10
  19. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Evil, your still typing the command into your Python shell. The command line is something different not linked to Python at all.

    No offence intended, but maybe you should learn a little more about computers before you try programming. Even my Mum knows what the command line is and she's a real novice .

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

  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    58
    Rep Power
    10
    i did use the command prompt and no matter what i use it just gives something about it bieng invalid. it says python is an invalid command
  22. #12
  23. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Ok, at least were on the right track. You get the invalid because python isnt on your PATH, under XP this is really easy to add but you can always worry about that later.

    So what you'll need to di is to cd to the directory you have Python installed in by doing:

    C:\> cd C:\Python23
    C:\Python23\>
    again, at the command line. After this all you need to do is type the line from before to start py2exe and everything should work fine .

    In theory,

    Mark.
    Last edited by netytan; August 3rd, 2004 at 10:55 AM.
    programming language development: www.netytan.com Hula

  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    58
    Rep Power
    10
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\kristin lewin>cd C:\Python23

    C:\Python23>setup.py py2exe
    'setup.py' is not recognized as an internal or external command,
    operable program or batch file.

    C:\Python23>files
    'files' is not recognized as an internal or external command,
    operable program or batch file.

    C:\Python23>cd c:\python23\files

    C:\Python23\files>setup.py py2exe
    Traceback (most recent call last):
    File "C:\Python23\files\setup.py", line 1, in ?
    from distutils.core import setup
    File "C:\Python23\lib\distutils\core.py", line 12, in ?
    import py2exe
    File "C:\Python23\Lib\site-packages\py2exe\__init__.py", line 64, in ?
    import distutils.dist, distutils.core, distutils.command, build_exe, sys
    File "C:\Python23\Lib\site-packages\py2exe\build_exe.py", line 5, in ?
    from distutils.core import Command
    ImportError: cannot import name Command

    C:\Python23\files>

    this is what it says now
  26. #14
  27. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Ok i dont have access to Windows in order to do this myself so you'll have to bare with me while i try to fabricate an example for you .

    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\kristin lewin>cd C:\Python23

    C:\Python23> python files\setup.py py2exe
    Try that and see what happens. Also just out of interest, do you have an admin account on this PC?

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

  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    58
    Rep Power
    10
    it just says the same massage as above

    and im not sure about the admin account.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo