如何在Python 3.4的oauth2 v.2中使用Consumer对象? [英] How should I use Consumer object in oauth2 v.2 in Python 3.4?
问题描述
我正在尝试通过oauth2软件包(第2版)使用Yelp的API,Python 3.4(在Anaconda的Spyder中)代码如下:
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)
我收到此错误消息:
AttributeError:模块"对象没有属性消费者"
AttributeError: 'module' object has no attribute 'Consumer'
我猜想在此版本的oauth2中不存在Consumer! 任何帮助将不胜感激,
I'm guessing Consumer doesn't exist in this version of oauth2! Any help would be appreciated,
推荐答案
使用pip install oauth2
默认安装oauth2存在一些问题.现在我在Anaconda的Python 2.7和Python 3.4上都尝试了,但是没有用.
您可以从复制代码(_ _ _ _ _.py) 放入您的_ _ init _ _ _.py文件,然后重新启动内核.
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.
_ _ _ _ _ _ .py文件的位置可以通过
Location of your _ _ init _ _ .py file can be found via
import oauth2 as oauth
print(oauth)
重新启动后,内核可能会请求可以通过pip search <library_name>
找到的库,然后执行pip install <library_name>
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屋!