3

After installing the facebook-sdk module here, and looking at other solutions here and elsewhere, I keep getting this error:

Traceback (most recent call last):
  File "facebook.py", line 1, in <module>
    import facebook
  File "/home/facebook/facebook.py", line 3, in <module>
    graph = facebook.GraphAPI(access_token='ACCESS TOKEN HERE')
AttributeError: 'module' object has no attribute 'GraphAPI'

For this very simple python code to authenticate...

import facebook

graph = facebook.GraphAPI(access_token='ACCESS TOKEN HERE')

print 'Workinnnn'

It says my module is installed and up to date, and I have installed both within (as suggested) a virtualenv and outside, and still get the error. I also definitely HAVE the module in usr/local/lib/python etc. dist packages... and it contains the class GraphAPI

Has anyone got a suggestion either:

1) What might be going wrong? 2) What to try to fix it? UNinstall something? 3) If there is another way other than pip to install the module... I don't normally use pip (but definitely have it installed and installed facebook-sdk from it) so if there's another way then I'd like to try...

Cheers :/

1 Answer 1

5

Solution = don't name your script the same as your module.

I'm an idiot, sigh...

Sign up to request clarification or add additional context in comments.

6 Comments

did the same thing as you haha
There are more idiots out there --blush-- Thx for posting this!
I am stuck on the same error: graph = facebook.GraphAPI(ACCESS_TOKEN) AttributeError: 'module' object has no attribute 'GraphAPI' -> Python 2.7.12 (default, Nov 19 2016, 06:48:10) Ubuntu
I tested: "from facebook import GraphAPI" on prompt and there is no error!
print facebook.__path__ -> /root/facebookenv/src/facebook-sdk/facebook
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.