So I'm trying to set up Tweepy so I can start programming with it.
How my first program looks:
#IMPORTING LIBRARIES
# * tweepy - Twitter API
import tweepy
#LISTING CREDENTIALS
_consumer_key = 'MYCONSUMERKEY'
_consumer_secret = 'MYCONSUMERSECRETKEY'
_access_token = 'MYACCESSTOKEN'
_access_token_secret = 'MYACCESSTOKENSECRET'
#OAUTHHANDLER INSTANCE
# * works over HTTP and authorizes devices, APIs, servers, and
# applications — is a standard that provides secure and delegated access.
auth = tweepy.OAuthHandler(_consumer_key, _consumer_secret)
auth.set_access_token(_access_token, _access_token_secret)
auth.secure = True
api = tweepy.API(auth)
#UPDATE STATUS
tweet = "Hello, world!"
api.update_status(status=tweet)
When I run this, I get the following error:
auth = tweepy.OAuthHandler(_consumer_key, _consumer_secret)
AttributeError: module 'tweepy' has no attribute 'OAuthHandler'
I feel it could be because of my file structure, but I have played around with moving files around with no luck.
Try import like this:
from tweepy.auth import OAuthHandler
auth = OAuthHandler(_consumer_key, _consumer_secret)
auth.set_access_token(_access_token, _access_token_secret)
Hope, it will help :)