我应该如何在 Python 3.4 的 oauth2 v.2 中使用 Consumer 对象? [英] How should I use Consumer object in oauth2 v.2 in Python 3.4?

查看:37
本文介绍了我应该如何在 Python 3.4 的 oauth2 v.2 中使用 Consumer 对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

consumer = oauth2.Consumer(CONSUMER_KEY, CONSUMER_SECRET)

我收到此错误消息:

<块引用><块引用><块引用>

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

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

解决方案

使用 pip install oauth2 默认安装 oauth2 存在一些问题.现在我在 Anaconda 上的 Python 2.7 和 Python 3.4 上都尝试了它,但它不起作用.您可以从 复制代码 (_ _ init _ _.py)在这里进入你的_ _ init _ _.py文件并重启你的内核.

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

找到

导入 oauth2 作为 oauth打印(oauth)

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

I am trying to use Yelp's API using oauth2 package (version 2), the Python 3.4 (in Anaconda's Spyder) code is like:

consumer = oauth2.Consumer(CONSUMER_KEY, CONSUMER_SECRET)

and I get this error message:

AttributeError: 'module' object has no attribute 'Consumer'

I'm guessing Consumer doesn't exist in this version of oauth2! Any help would be appreciated,

解决方案

There is some problem with default installation of oauth2 using pip install oauth2. Right now I tried it on both Python 2.7 and Python 3.4 on Anaconda, its not working. You can copy the code ( _ _ init _ _.py) from here into your _ _ init _ _.py file and restart your kernel.

Location of your _ _ init _ _ .py file can be found via

import oauth2 as oauth
print(oauth)

After restart, kernel may ask for libraries which can be found via pip search <library_name> and then doing the pip install <library_name>

这篇关于我应该如何在 Python 3.4 的 oauth2 v.2 中使用 Consumer 对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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