Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'module' object has no attribute 'OAuthHandler' #490

Closed
panoptikum opened this issue Oct 7, 2014 · 16 comments
Closed

AttributeError: 'module' object has no attribute 'OAuthHandler' #490

panoptikum opened this issue Oct 7, 2014 · 16 comments
Labels
Bug This is regarding a bug with the library

Comments

@panoptikum
Copy link

Dear Tweepy Team,

I'm keep running into this error and I'm really frustrated. Have I installed it correctly? Or where could this error come from? I have no clue:

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'module' object has no attribute 'OAuthHandler'

Any advice is appreciated!

Kind regards

@arhuaco
Copy link

arhuaco commented Oct 7, 2014

Try:

from tweepy.auth import OAuthHandler

@panoptikum
Copy link
Author

Unfortunately, it doesn't change anything. More ideas?

@arhuaco
Copy link

arhuaco commented Oct 7, 2014

I mean:

from tweepy.auth import OAuthHandler

(then...)

auth = OAuthHandler(consumer_key, consumer_secret)

@panoptikum
Copy link
Author

without the tweepy before OAuthHandler it seems to work, but why is this so?

@panoptikum
Copy link
Author

I assume I'll get the error wherever I put tweepy before a function?

@panoptikum
Copy link
Author

A clean uninstall with pip and reinstall helped. So far, I'm not getting this error any longer. Thank you!

@Aaron1011
Copy link
Contributor

I fixed this in d9d5a86. Sorry for the problems!

@panoptikum
Copy link
Author

Thanks for helping out and it's good to know that there was an error in the code. All I complained about before is resolved now, but when I try a simple request such as:

user = tweepy.api.get_user('twitter')

I get the following error:

user = tweepy.api.get_user('twitter')
Traceback (most recent call last):
File "", line 1, in
File "/Library/Python/2.7/site-packages/tweepy/binder.py", line 230, in _call
return method.execute()
File "/Library/Python/2.7/site-packages/tweepy/binder.py", line 203, in execute
raise TweepError(error_msg, resp)
tweepy.error.TweepError: [{u'message': u'Bad Authentication data', u'code': 215}]

My feeling is that I'm just too dumb to authenticate properly.

@Aaron1011
Copy link
Contributor

Oh, sorry. I've considered removing that unauthenticated instance.

Basiclly, all Twitter API endpoints require authentication (they didn't use to, years, ago, thus tweepy.api).

You have to create an instance of tweepy.API, by creating an instance of OAuthHandler. Here's an example, using the consumer and access tokens/secrets given to you from the app you create with Twitter on their dev site.

@panoptikum
Copy link
Author

I did this and it works fine, but when I'll try to go beyond the example with the above code I'll get the same errors again.

@panoptikum
Copy link
Author

OK. I continued using tweepy before a command such as get_user. On my behalf, I'm new to Python and programming in general. Thank you for all your patience.

Instead of:

user = tweepy.api.get_user('sukutuu')

This is working:

user = api.get_user('sukutuu')

@Aaron1011
Copy link
Contributor

Right, sorry, I should have mentioned that.

You need to use the authenticated API instance you created for all calls you make. tweepy.api will never work, and is only used for internal testing.

@varunjain97
Copy link

Dear Tweepy Team,
when i am runing from tweepy.auth import OAuthHandler then i got an error please debug it
this is my error
'path' must be None or a list, not <class '_frozen_importlib_external._NamespacePath'>

@Lokesh2Lokesh
Copy link

Dear Tweepy Team,

I keep running into this error and I'm really frustrated. Have I installed it correctly? Or where could this error come from? I have no clue:

auth.set_access_token(config.access_token, config.access_secret)
AttributeError: 'module' object has no attribute 'access_token'

Any Advice is Appreciated

@zackxo
Copy link

zackxo commented Mar 6, 2019

its an O.

@Harmon758
Copy link
Member

Note, as previously stated, this issue was fixed with d9d5a86 as part of v3.0.0.

@varunjain97 That is not related to this issue and doesn't even seem to be related to this library.
A cursory scan of the results for a quick search for that error seems to point to it being an issue with Spyder.

@MVL10 This is not related to this issue and is not an issue with the library.
This is an error in your project configuration. Make sure that you're exposing the access_token in your config module.

@Harmon758 Harmon758 added the Bug This is regarding a bug with the library label Apr 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is regarding a bug with the library
Projects
None yet
Development

No branches or pull requests

7 participants