SyntaxError: invalid syntax

Discussion in 'Python' started by DIBS, Dec 27, 2005.

  1. DIBS

    DIBS Guest

    I'm new to Python and I don't understand what I'm doing wrong.

    I'm running windows xp.

    In the command line window, I type:
    Python Sudoku.py

    and I get the response"

    SyntaxError: invalid syntax

    If anyone cane help me I'd be very grateful.
     
    DIBS, Dec 27, 2005
    #1
    1. Advertisements

  2. Please post the *full* traceback of the error, not just the last
    description.

    For example, something like this:
    File "<stdin>", line 1
    x = x+*9
    ^
    SyntaxError: invalid syntax


    Just "SyntaxError" on its own is not enough to tell what is going on,
    except to say that it sounds like a bug in the program you are trying to
    run.
     
    Steven D'Aprano, Dec 27, 2005
    #2
    1. Advertisements

  3. or that he's using a program written for a newer version of Python than
    the one he has on his machine...

    </F>
     
    Fredrik Lundh, Dec 27, 2005
    #3
  4. DIBS

    DIBS Guest

    python sudoku.py
    File "<stdin>", line 1
    python sudoku.py
    ^




    Thanks for your help.
    The above is the extact message.

    DIBS
     
    DIBS, Dec 27, 2005
    #4
  5. that looks like the Python interpreter window, not the Windows command-
    line window.

    To run complete Python programs, type "python filename" in the Windows
    command-line window (or double-click on filename from the explorer).

    the FAQ has more information:

    http://www.python.org/doc/faq/windows.html#how-do-i-run-a-python-program-under-windows

    </F>
     
    Fredrik Lundh, Dec 27, 2005
    #5
  6. Based on the ">>>" prompt, I'd say you tried to type this
    into the python interactive interpreter. It's supposed to be
    a shell command -- i.e. you *invoke* the python interpreter
    to run the file from the command line.

    If you are already running python, then you might get what
    you want by importing the module:

    but whether that's what you really want or not depends on
    how the module is meant to be used (is it a "module" or a
    "script"?).

    Cheers,
    Terry
     
    Terry Hancock, Dec 27, 2005
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.