Error while importing facebook module in Python

Praveenks picture Praveenks · Apr 10, 2014 · Viewed 9.4k times · Source

I have installed facebook-sdk using below mentioned command:

pip install facebook-sdk

But while importing it, I am facing an issue:

import facebook
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python33\lib\site-packages\facebook.py", line 222
    except urllib2.HTTPError, e:
                            ^
SyntaxError: invalid syntax

How can I fix this?

Answer

logc picture logc · Apr 10, 2014

That is an old syntax for catching exceptions. It should have been replaced with the keyword as since Python 2.6, and it is probably not supported at all on Python 3.

Try to find another library that does support Python 3, or consider downgrading to Python 2.6 (which should really be a last-resort option).

You can review all details on PEP 3110.