python - tweepy - ModuleNotFoundError
问题描述
我在 Python 中有一个脚本来使用 Tweepy 收集数据。当我运行它时,我收到了这条消息,ModuleNotFoundError: No module named 'tweepy.auth'; 'tweepy' is not a package
我已经做了一个 pip install tweepy,我的 python 版本是 3.8.0。这是我的代码的开头(写在崇高的文本上):
import tweepy
from tweepy.auth import OAuthHandler
consumer_key = "XXX"
consumer_secret = "XXX"
access_token = "XXX"
access_token_secret = "xxx"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
我的谜底在哪里?谢谢
解决方案
您是否尝试过不导入 OAuthHandler?你可能不需要。Tweepy 的文档建议:
import tweepy
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
推荐阅读
- eclipse - Javafx 项目在 Eclipse 上执行,但不是通过命令提示符执行
- android - 如何根据从服务器接收的数据延迟多次重复 API 调用?
- java - Gradle can not compile the code with the generated sources by annotationProcessor
- python - Django 迁移失败 'QuerySet' 对象没有属性 'objects'
- android - 此 App Bundle 包含本机代码,并且您尚未上传调试符号
- java - 如何将 MouseWheel 事件捕获/转发到多个对象?
- ruby - 使用 ruby 从 xml 文档中删除空格
- ruby-on-rails - 为 Rails 中的动态属性添加唯一性验证
- scala - 如何从键中获取值,值从scala中的map reduce作业中获取
- wordpress - 按类别设置最小订单数量(Woocommerce)