Search code examples
pythontwittertweepygeanypython-twitter

Tweepy Error - Python -


I install Tweepy and Python-Twitter and try basic code

import twitter
api = twitter.Api(consumer_key=["X"],
                  consumer_secret=["X"],
                  access_token_key=["35X-X"],
                  access_token_secret=["X"])
print(api.VerifyCredentials())

and i tried to run:

Traceback (most recent call last):
  File "tweepy.py", line 1, in <module>
    import twitter
  File "/home/rodney/twitter.py", line 1, in <module>
    import tweepy
  File "/home/rodney/tweepy.py", line 2, in <module>
    api = twitter.Api(consumer_key=["X"],
AttributeError: module 'twitter' has no attribute 'Api'

get this error what i do:

if try code:

import twitter
import tweepy
api = twitter.Api(consumer_key=["X"],
                  consumer_secret=["X"],
                  access_token_key=["35X-X"],
                  access_token_secret=["X"])
print(api.VerifyCredentials())

error:

Traceback (most recent call last):
  File "tweepy.py", line 1, in <module>
    import tweepy
  File "/home/rodney/tweepy.py", line 2, in <module>
    import twitter
  File "/home/rodney/twitter.py", line 10, in <module>
    auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
AttributeError: module 'tweepy' has no attribute 'OAuthHandler'

Solution

  • Try this For what you want to do here is the code using tweepy import tweepy auth = tweepy.OAuthHandler(consumer_token, consumer_secret) auth.set_access_token(key, secret) resp= tweepy.API(auth) The rest is upon you whatever you want to do. For that you will need cursors, which can be found over here http://docs.tweepy.org/en/v3.5.0/cursor_tutorial.html