Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook-sdk python module has no attribute GraphAPI

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 :/

like image 729
joep1 Avatar asked May 15 '26 09:05

joep1


1 Answers

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

I'm an idiot, sigh...

like image 58
joep1 Avatar answered May 16 '26 21:05

joep1



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!