0

I installed Python 3.4 on Windows 7. Made changes to environment variables. This is my User Variable:

Variable: PATH Value: C:\Python34\Scripts;

This is my System Variables:

Variable: Path Value: C:\ProgramData\Oracle\Java\javapath;C:\Python34;C:\Python34\Scripts;

The error that I get When I am trying to run it from command prompt.

Microsoft Windows [Version 6.1.7600]
    Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

    C:\Users\Batman>cd C:\Python34

    C:\Python34>cd Scripts

    C:\Python34\Scripts>python hello.py
      File "hello.py", line 1
        print "Hello";
                    ^
    SyntaxError: Missing parentheses in call to 'print'

    C:\Python34\Scripts>

What else did I miss installing???

EDIT: I moved to Python 2.x. While downloading Python from official website, I saw something like this: Windows x86 MSI program database (2.7.8) What does this exactly mean??

  • seems like your installation is just fine. the problem is syntax error like falsetru explained in his answer below – Elisha Nov 11 '14 at 13:58
  • @Elisha I am not able to install any modules using easy_install. How should I rectify this? – user3206062 Nov 11 '14 at 14:26

2 Answers2

1

In Python 3.x, print is a function. (not a statement) You should call it as a function form.

print("Hello")

BTW, you don't need to append ; at the end of the statement in Python.

falsetru
  • 357,413
  • 63
  • 732
  • 636
  • I am also trying to install modules like BeautifulSoup but I get the same error. – user3206062 Nov 11 '14 at 13:58
  • @user3206062, Are you trying to install Beautiful Soup 3? That version supports only Python 2.x. Try to install Beautiful Soup 4. – falsetru Nov 11 '14 at 14:00
  • I am not able to install BeautifulSoup using easy_install. How would I do this?? It worked in 3.4, but since I shifted to 2.7, easy_install is not working. – user3206062 Nov 11 '14 at 14:28
  • @user3206062, Since Python 3.4, `pip` is included. In lower version, you need to install `pip` yourself. Following [this page - pip installation](https://pip.pypa.io/en/latest/installing.html) will help you. After installation, `pip install bs4` (to install BS4) or `pip install BeautifulSoup` (to install BS3) – falsetru Nov 11 '14 at 14:29
1

It's not a problem with the install, it's a problem with version compatibility.

In Python 3, the print statement changed, and it needs parenthesis like: print("Hello"). So you're trying to run Python 2 code with the Python 3 interpreter. If you notice, you're error message doesn't say anything about an error in your install at all.

Here is some info on the differences between 2 and 3: https://wiki.python.org/moin/Python2orPython3

Edit: I saw you mentioned Beautiful Soup. From the Soup homepage:

Beautiful Soup 3 works only under Python 2.x.

...

Beautiful Soup 4 works on both Python 2 (2.6+) and Python 3.

So you'll need Soup 4 or higher.

nanny
  • 1,098
  • 9
  • 19
  • So should I work in Python 2.x? Because I am in the learning curve right now. – user3206062 Nov 11 '14 at 14:04
  • The differences, though incompatible, will appear very insignificant to you at first. My opinion is that the version you learn first doesn't matter, but I'd recommend 3, because it's current. If you are following a tutorial use the tutorial's version (which appears to be 2). You can install both at the same time to different folders if you want to. For more info read the first link I linked. – nanny Nov 11 '14 at 14:08