【发布时间】:2017-12-31 20:11:14
【问题描述】:
我已经安装了 tweepy,并且我的代码中包含“import tweepy”没有问题。 但是,当我尝试在 tweepy 中使用任何东西时,我遇到了以下错误:“ImportError: cannot import name 'OAuthHandler'”
from tweepy import OAuthHandler
consumer_token = 'XXX'
consumer_secret = 'YYY'
auth = tweepy.OAuthHandler(consumer_token, consumer_secret)
stackoverflow 上的所有解决方案都说要试试这个,但它仍然对我不起作用
from tweepy.auth import OAuthHandler
consumer_token = 'XXX'
consumer_secret = 'YYY'
auth = tweepy.OAuthHandler(consumer_token, consumer_secret)
【问题讨论】:
-
一般来说,如果你使用
from xxx import yyy,那么你不应该使用它作为xxx.yyy(),而只是调用yyy()。否则它将无法正常工作。只有当你使用import xxx时,你才应该使用xxx.yyy()。
标签: python twitter web-crawler twitter-oauth tweepy