Tweepy未定义

时间:2018-10-08 00:27:20

标签: tweepy

我收到此消息:

  

auth = tweepy.OAuthHandler(consumer_key,Consumer_secret)

     

NameError:未定义名称“ tweepy”

尝试以下方法:

from credentials import *

import tweepy
from time import sleep

from tweepy.auth import OAuthHandler

auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

for tweet in tweepy.Cursor(api.search,q='#Kanye').items(10):
        try:
                print('Tweet by @' + tweet.user.screen_name)

        except tweepy.TweepError as e:
                print(e.reason)

        except StopIteration:
                break

1 个答案:

答案 0 :(得分:-1)

确保您未将脚本命名为tweepy.py