tags:

views:

98

answers:

3

I am trying to install python on windows, and this is my first day on python. Install goes well on windows 7 x64. But almost all scripts fails. I am trying to install celery and running following command on celery folder.

python setup.py build

and it fails, following is an error

  File "setup.py", line 40
except ImportError, exc:
                      ^
SyntaxError: invalid syntax

also following fails, which is valid print command i think.

>>> print 'a'
  File "<stdin>", line 1
    print 'a'
            ^
SyntaxError: invalid syntax

I am sure i am missing something here. Any idea what makes it fail?

Edit: Below is summary of tasks i had to go through to get python working, made notes for myself but putting it here as well if it can help anyone

Install python and celery
=========================
-celery does not work with python3, so install latest python2
-install windows install for python2
-add C:\python2X to %PATH%
-set python path for lib
        set PYTHONPATH=%PYTHONPATH%;c:\python2x
-install setuptools
    http://pypi.python.org/pypi/setuptools
    for x64 install does not work use
        python setup.py install
-then can use easy_install
-now just use easy_install to install everything
+3  A: 

A likely cause is version incompatibility, as Vincent Savard pointed out. Python 3 is not backwards compatible with Python 2 if print 1 doesn't work, but print(1) does, then you are running python 3, which seems to be the case

Martijn
@Martijn and Gadarene upvoters: -1 `print(1)` works in any version of Python; it's equivalent to `print (1)` which is equivalent to `print 1`
John Machin
like I said before: It's not that `print(1)` doesn't work in newer versions of python 2 (I think 2.4), but that `print 1` doesn't work in python 3
Martijn
A: 

Yeah you're probably running python 3. Try print("hello world")

If that works then you're running python 3

ultimatebuster
-1 Utterly useless answer. If that works, you're running Python, period. Python 1 and Python 2 treat that as `print any_old_expression`, which in this case evaluates to `"hello world"` [tested with Python 1.5.2, 2.1, and 2.7] -- try it and see. The two syntax errors listed by the OP are conclusive evidence that the OP is trying to execute pre-3 script(s) with Python 3.x
John Machin
What I'm trying to say is that if print "something" doesn't work and print("something") works, you're running python 3.
ultimatebuster
A: 

Print statements with parentheses work fine in newer versions of python 2. The best way to determine what version you are running is to just type 'python --version' or just type python and carefully read what it says.

jgritty
What you are saying is correct, but `print "hello world"` does work with python 2, and doesn't work with python 3, even if `print("hello world")` probably works in both
Martijn
@jgritty: -1. print statements with parentheses work fine in Python 1 and 2. `--version` is not the best; it works only from 2.5 onwards. Use `-V`.
John Machin
Obviously, you failed to read my entire answer. Last time I checked, the command: 'python' works in all versions of python, and includes the version information.
jgritty
Also, why not read the original question. The most likely scenario is that he is running 3.x and not 2.4 or older.
jgritty