Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with tweepy OAuthHandler

Tags:

python

tweepy

I'm new here and kind of unexperienced with python, so sorry if the question is trivial.

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)

of course xxx,yyy,etc are being set in my script with API key, secret, access token etc

I get this error:

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.

Thanks Andrea

like image 703
Andrea Colombo Avatar asked Sep 27 '14 13:09

Andrea Colombo


1 Answers

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)

Reference here https://github.com/tweepy/tweepy/blob/master/tweepy/auth.py#L29

like image 181
dhana Avatar answered Nov 15 '22 11:11

dhana