Python Facebook SDK:'module'对象没有属性'GraphAPI' [英] Python Facebook SDK: 'module' object has no attribute 'GraphAPI'

查看:399
本文介绍了Python Facebook SDK:'module'对象没有属性'GraphAPI'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Facebook SDK for Python运行一个基本的例子。我试着从这个命令行中完成这个教程使用 pip install facebook pip install facebook-sdk 成功完成...):

I am trying to run a basic example with the Facebook SDK for Python. I tried doing exactly what this tutorial does from the command line (with "pip install facebook" and "pip install facebook-sdk" successfully done first...):

import Facebook 工作正常,但 graph = facebook.GraphAPI()给出以下内容错误:

import Facebook works okay, but graph = facebook.GraphAPI() gives the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'GraphAPI'

我不是真的熟悉模块的工作原理,但它看起来像 facebook 不知何故不认识!还有其他的东西在这里丢失。从命令行,我尝试了这些事情调查:

I'm not imtimately familiar with how modules work, but it looks like facebook somehow isn't recognized at all! Or something else is missing here. From the command line, I tried these things to investigate:

>>>dir(facebook)

输出:

['__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__version__']

和...

>>>help(facebook)

输出:

Help on package facebook:

NAME
    facebook - TODO: Document your package.

FILE
    /Library/Python/2.7/site-packages/Facebook-0.0-py2.7.egg/facebook/__init__.py

PACKAGE CONTENTS


DATA
    __loader__ = <zipimporter object "/Library/Python/2.7/site-packages/Fa...
    __version__ = 'TODO: Enter a version'

VERSION
    TODO: Enter a version

(END) 

...但我仍然坚持,我需要输入一个版本,以某种方式让事情完全实例化吗?还是可以做别的?

...But I'm still stuck. Do I need to "enter a version" to somehow get the thing to fully instantiate? Or could it be something else?

推荐答案

如果您正在使用Ubuntu或Debian,只需执行以下命令即可获得此工作

If you are using Ubuntu or Debian, Just execute the following commands to get this working

sudo pip uninstall facebook
sudo pip uninstall facebook-sdk
sudo pip install facebook-sdk

对于其他操作系统,只需删除 facebook facebook-sdk 包,只安装 facebook-sdk

For other operating systems, just remove facebook and facebook-sdk packages and install only facebook-sdk.

母鸡执行该程序,它将工作。看起来像 facebook 模块是一个虚拟模块。我们实际需要的只是 facebook-sdk

And then execute that program, it will work. Looks like facebook module is a dummy module. What we actually need is facebook-sdk only.

这篇关于Python Facebook SDK:'module'对象没有属性'GraphAPI'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆