1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Can't get Python to work

Discussion in 'Software Development' started by mehehe, Apr 17, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. mehehe

    mehehe Thread Starter

    Joined:
    Mar 10, 2010
    Messages:
    18
    I downloaded Python for the first time today and went to start compiling a code but when I did, it said there was a Syntax error. it highlighted the "2" in "3.2" at the top of IDLE. I tried deleting the 2 but it did the same thing and highlighted the "." after the "3" instead. Same thing when I tried Python 2.7. Both versions were the Windows x86 MSI Installer. Any ideas?
     
  2. Ent

    Ent Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,467
    First Name:
    Josiah
    I don't know python, and what you're saying may make perfect sense to someone who does. But in my experience if someone wants help with code that won't compile the most helpful thing they can do is provide the code you're using.
     
  3. mehehe

    mehehe Thread Starter

    Joined:
    Mar 10, 2010
    Messages:
    18
    thanks for the reply, Ent. It seems to be occurring with any code I try to run. I've tried:
    print("hello, world")
    several mathematical codes, like 1+1 and 15+32
    and several other codes; all resulted in the same error.
    Note: the codes worked in the IDLE shell, the problem comes up when I run the module. Also, here are the details of the two versions of Python I've tried:
    Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win32
    and
    Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32
     
  4. Ent

    Ent Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,467
    First Name:
    Josiah
    Are you including that line at the top of your script?
    ie would your file say
    Code:
    Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
    Type "copyright", "credits" or "license()" for more information.
    print("hello, world")
    exit()
    as it says in the shell or simply
    Code:
    print("hello, world")
    exit()
    You don't need any heading for a python script.
     
  5. mehehe

    mehehe Thread Starter

    Joined:
    Mar 10, 2010
    Messages:
    18
    I've tried it with and without the heading. Without the heading, it highlights the second ">" as the error instead. I've also tried it without any ">"s, and it highlighted "world" instead
     
  6. Ent

    Ent Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,467
    First Name:
    Josiah
    If you create a file in notepad, with only the contents
    print("hello, world")
    and save that as Hello.py,
    can you doubleclick that and run it successfully?
     
  7. mehehe

    mehehe Thread Starter

    Joined:
    Mar 10, 2010
    Messages:
    18
    the file opened
     
  8. mehehe

    mehehe Thread Starter

    Joined:
    Mar 10, 2010
    Messages:
    18
    sorry, I don't know if that means it runs or not (I have zero experience with coding, sorry)
     
  9. Ent

    Ent Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,467
    First Name:
    Josiah
    I don't know enough about Python to tell what's happening. If it's opening with notepad then you probably saved it as a .txt file (such as programname.py.txt). Make sure that you choose "All files" when using Save as under notepad. Other than that I can't be sure.
     
  10. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/991871

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice