Skip to content Skip to sidebar Skip to footer

Twitter Module Python 'module' Object Has No Attribute Oauth

Im trying to follow this basic example here. Code import twitter # XXX: Go to http://dev.twitter.com/apps/new to create an app and get values # for these credentials, which you'l

Solution 1:

You don't mention what OS you are using. Is it Ubuntu or Debian?

If so, apt-get install python-twitter installs the wrong package for your needs. Install the correct package like so:

sudo apt-get purge python-twitter
sudo pip install twitter 

Additionally, you should change the name of your program so that it isn't identical to the module you are importing.

Solution 2:

Instead of twitter.oauth.Oauth, use twitter.Api

importtwitterapi= twitter.Api(consumer_key='consumer_key',
                      consumer_secret='consumer_secret',
                      access_token_key='access_token',
                      access_token_secret='access_token_secret')

Details Here

Solution 3:

I had the same problem and here is what helped me out. I first found out all the the packages that were related to twitter,which in my case were tweepy and twitter. I uninstalled both of them and re installed twitter. So far so good. It worked for me.

help("modules")

The main problem was not with the OAuth but installation of multiple twitter packages.

Solution 4:

I had similar problem. I had python-twitter package installed. I kept getting the same exact error. By removing python-twitter like:

(!pip uninstall python-twitter)

in Ipython console and installing twitter package now it works fine.

I hope that helps.

Solution 5:

Try tweepy instead, I found it does a much better job of handling twitter authentication

importtweepyCONSUMER_KEY=''
CONSUMER_SECRET =''
OAUTH_TOKEN = ''
OAUTH_TOKEN_SECRET = ''
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(OAUTH_TOKEN, OAUTH_TOKEN_SECRET)

api = tweepy.API(auth)

Post a Comment for "Twitter Module Python 'module' Object Has No Attribute Oauth"