2014-09-27 74 views
4

我在這裏新的,與Python種雛,很抱歉,如果這個問題實在是微不足道。誤差tweepy OAuthHandler

我有這個簡單的腳本,以獲取給定的Twitter用戶的追隨者:

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密鑰,祕密,訪問令牌等

我得到這個錯誤:

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' 

有沒有人能幫助我嗎? 不能明白我在做什麼錯。

感謝 安德烈

回答

5

tweepy module對象有沒有屬性 'OAuthHandler',你應該導入這個樣子,

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

+0

謝謝!不能投票(我的代表仍然太低),但工程。 – 2014-09-27 16:28:57

+0

@AndreaColombo你能接受我的答案。 – dhana 2014-09-28 11:14:52

+0

完成!再次感謝你! – 2014-09-30 08:47:04