【问题标题】:How should I use Consumer object in oauth2 v.2 in Python 3.4?我应该如何在 Python 3.4 的 oauth2 v.2 中使用 Consumer 对象?
【发布时间】:2015-09-06 13:43:30
【问题描述】:

我正在尝试通过 oauth2 包(版本 2)使用 Yelp 的 API,Python 3.4(在 Anaconda 的 Spyder 中)代码如下:

consumer = oauth2.Consumer(CONSUMER_KEY, CONSUMER_SECRET)

我收到此错误消息:

AttributeError: 'module' 对象没有属性 'Consumer'

我猜消费者在这个版本的 oauth2 中不存在! 任何帮助将不胜感激,

【问题讨论】:

标签: python api oauth consumer


【解决方案1】:

使用pip install oauth2 的默认安装 oauth2 存在一些问题。现在我在 Anaconda 上的 Python 2.7 和 Python 3.4 上都试过了,它不起作用。 您可以将代码 (_ _ init _ _.py) 从 here 复制到您的 _ _ init _ _.py 文件中并重新启动您的内核。

您的 _ _ init _ _ .py 文件的位置可以通过

找到
import oauth2 as oauth
print(oauth)

重新启动后,内核可能会要求可以通过pip search <library_name>找到的库,然后执行pip install <library_name>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-20
    • 1970-01-01
    • 2016-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-06
    相关资源
    最近更新 更多