How should I use Consumer object in oauth2 v.2 in Python 3.4?

╄→尐↘猪︶ㄣ 提交于 2019-12-10 11:47:53

问题


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,


回答1:


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>



来源:https://stackoverflow.com/questions/30957373/how-should-i-use-consumer-object-in-oauth2-v-2-in-python-3-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!