tweepy OAuthHandler 出错 [英] Error with tweepy OAuthHandler
本文介绍了tweepy OAuthHandler 出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是新来的,对 python 没有经验,如果问题不重要,很抱歉.
I'm new here and kind of unexperienced with python, so sorry if the question is trivial.
我有这个简单的脚本,用于获取给定 Twitter 用户的关注者:
I have this simple script, to fetch followers of a given twitter user:
import time
import tweepy
consumer_key="xxx"
consumer_secret="yyy"
access_token="zzz"
access_token_secret="www"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
当然,xxx、yyy 等是在我的脚本中设置的,其中包含 API 密钥、秘密、访问令牌等
of course xxx,yyy,etc are being set in my script with API key, secret, access token etc
我收到此错误:
c:\Development>c:\Python27\python.exe get_followers.py
Traceback (most recent call last):
File "get_followers.py", line 4, in
auth = tweepy.OAuthHandler('xxx', 'yyy')
AttributeError: 'module' object has no attribute 'OAuthHandler'
有人能帮我吗?无法理解我做错了什么.
Is anyone able to help me? Can't understand what am I doing wrong.
谢谢安德里亚
推荐答案
tweepy module
对象没有属性 'OAuthHandler',你应该这样导入,
The tweepy module
object has no attribute 'OAuthHandler',You should import like this,
from tweepy.auth import OAuthHandler
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
参考这里https://github.com/tweepy/tweepy/blob/master/tweepy/auth.py#L29
这篇关于tweepy OAuthHandler 出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文