我正在尝试使用tweepy创建一个twitter机器人,并将其上传到一个可以24/7运行的虚拟环境中。
不幸的是,我被困在了基本的东西上。
首先,我无法为python3导入tweepy (我相信我的虚拟环境运行python2.7是出于某种原因),我不得不克隆它(git clone git://github.com/joshthecoder/tweepy.git),当然,我还要再次安装python3。
即使这样,我仍然得到了ImportError:没有名为'tweepy.auth'的模块
这是我运行的代码。有什么建议吗?
import tweepy
from tweepy.auth import OAuthHandler
auth = tweepy.OAuthHandler(consumer_key,consumer_secret)
auth.set_access_token(access_token,access_token_secret)
auth.secure = True
api = tweepy.API(auth)我的虚拟环境是一个运行在ubuntu上的数字海洋服务器。
发布于 2017-11-03 20:05:31
试一试
import tweepy
from tweepy import 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)
public_tweets = api.home_timeline()
for tweet in public_tweets:
print tweet.texthttps://stackoverflow.com/questions/47103635
复制相似问题