即使安装了tweepy,也显示 "没有名为tweepy的模块"。为什么呢?

问题描述 投票:0回答:1

我想通过tweepy使用twitter API进行文本挖掘。它安装成功了,但当我运行我的代码时,它显示出

from tweepy import StreamListener ImportError: 没有名为tweepy的模块

我在atom上用Python 3.7.1写的代码。我使用的是Windows 10。

我为此写了以下代码。

from tweepy import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream

access_token = "********"
access_token_secret = "*************"
consumer_key = "*************"
consumer_secret = "***************"


    def on_data(self, data):
        print data
        return True

    def on_error(self, status):
        print status


if __name__ == '__main__':

    l = StdOutListener()
    auth = OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)
    stream = Stream(auth, l)

    stream.filter(track=['python', 'javascript', 'ruby'])```
python tweepy
1个回答
0
投票

你可能在pycharm中使用了不同的python环境,因为你安装了几次pip。尝试使用以下步骤配置准确的python解释器。PyCharm, Settings -> Project Interpreter -> 这将在右上方显示已安装的包列表和专用解释器。在下拉菜单中试试你合适的解释器。enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.