Python Tweepy:错误的身份验证数据

Python Tweepy:错误的身份验证数据,python,tweepy,Python,Tweepy,我一直试图在一些关于La Sagrada Familia的推特上做一些基本的情绪分析,但我一辈子都不明白为什么会出现这种basd认证数据错误: Traceback (most recent call last): File "saDemo.py", line 15, in <module> public_tweets = api.search('') File "/Users/declancasey/opt/miniconda3/lib/

我一直试图在一些关于La Sagrada Familia的推特上做一些基本的情绪分析,但我一辈子都不明白为什么会出现这种basd认证数据错误:

Traceback (most recent call last):
  File "saDemo.py", line 15, in <module>
    public_tweets = api.search('')
  File "/Users/declancasey/opt/miniconda3/lib/python3.8/site-packages/tweepy/binder.py", line 252, in _call
    return method.execute()
  File "/Users/declancasey/opt/miniconda3/lib/python3.8/site-packages/tweepy/binder.py", line 234, in execute
    raise TweepError(error_msg, resp, api_code=api_error_code)
tweepy.error.TweepError: [{'code': 215, 'message': 'Bad Authentication data.'}]

我使用了您的代码,无法再现错误:
Python 3.7.4
我建议您通过登录到您的Twitter开发者帐户来检查API密钥,或者尝试使用其他密钥

import tweepy
from textblob import TextBlob

consumer_key = key[0]
consumer_secret = key[1]
access_token = key[2]
access_token_secret = key[3]
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
public_tweets = api.search("La Sagrada Familia")
for tweet in public_tweets:
    print(tweet.text)
    analysis = TextBlob(tweet.text)
    print(analysis.sentiment)
这是我得到的输出:(我已经从输出中删除了URL)

El Evangelio del dia 27 DE DICIEMBRE–多明戈-萨格拉达家族:耶稣、玛丽亚和何塞-圣胡安埃文…
情绪(极性=0.0,主观性=0.0)
LSE讲师:《萨格拉达家族》(B),2020年第27期,YouTube网站
情绪(极性=0.0,主观性=0.0)
劳德斯2020/12/27#劳德斯·弗雷内尔森家族节日
情绪(极性=0.0,主观性=0.0)
LECTIO 2020/12/27 ESPIRITUAL讲座#萨格拉达家庭节日酒店
情绪(极性=0.0,主观性=0.0)
RT@DespertaFerro11:Els que Estigue demía prop de la Sagrada Família,passeu a donar support a@juntschcat!这是我们的必需品#军…
情绪(极性=0.0,主观性=0.0)

RT@HdadBorriquita:我很感激,尽管我已经尝试过了,甚至在几次不同的时候重新生成了它们
import tweepy
from textblob import TextBlob

consumer_key = key[0]
consumer_secret = key[1]
access_token = key[2]
access_token_secret = key[3]
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
public_tweets = api.search("La Sagrada Familia")
for tweet in public_tweets:
    print(tweet.text)
    analysis = TextBlob(tweet.text)
    print(analysis.sentiment)