我正在尝试使用AWS进行情绪分析,如下节所述 http://docs.aws.amazon.com/gettingstarted/latest/emr/getting-started-emr-sentiment-tutorial.html
一切都很顺利,直到我遇到以下错误 [ec2用户@ip-10-65-140-113情感]$ls 在此处输入代码collector.py twaiter.py twaiter.pyc twitterparams.py
[ec2-user@ip-10-65-140-113 sentiment]$ **collector.py kindle**
-bash: collector.py: command not found
[ec2-user@ip-10-65-140-113 sentiment]$ python collector.py kindle
Traceback (most recent call last):
File "collector.py", line 6, in <module>
from twaiter import TWaiter
File "/home/ec2-user/sentiment/twaiter.py", line 5, in <module>
from tweepy import StreamListener
**ImportError: No module named tweepy**
任何关于这可能是什么原因的帮助。twaiter.py包含以下内容。我打开twaiter.py看到5号线,就在这里
[ec2-user@ip-10-65-140-113 sentiment]$ vi twaiter.py
1 # based on http://badhessian.org/2012/10/collecting-real-time-twitter-data-w ith-the-streaming-api/
2 # with modifications by http://github.com/marciw
3 # requires Tweepy https://github.com/tweepy/tweepy
4
5 from tweepy import StreamListener
6 import json, time, sys
7
8 class TWaiter(StreamListener):
9
10 # see Tweepy for more info
11
12 def __init__(self, api = None, label = 'default_collection'):
13 self.api = api or API()
14 self.counter = 0
15 self.label = label
16 self.output = open(label + '.' + time.strftime('%b%d-%H%M') + '.txt ', 'w')
17 self.deleted = open('deleted_tweets.txt', 'a')
18
19 def on_data(self, data):
20 # The presence of 'in_reply_to_status' indicates a "normal" tweet.
@
消息“ImportError:No module named tweepy”清楚地显示ec2机器没有安装tweepy库。因此,当运行当前的python脚本时,它无法找到它,因此会出现导入错误。
有几种方法可以安装tweepy。Linux机器中的一个简单方法是
sudo pip安装tweepy
其他方式包括:
http://code.google.com/p/tweepy/
您可以在同一个Google代码链接中找到它的教程wiki页面。
要用easy_install安装,只需运行easy_install tweepy
要与git一起安装:
git克隆git://github.com/joshthecoder/tweepy.git
cd特威比
python setup.py安装 要从源代码安装它,请从http://pypi.python.org/pypi/tweepy下载源代码,然后运行以下命令:
焦油xzvf tweepy-1.7.1.焦油gz
cd-tweepy-1.7.1
python setup.py安装
详情请参阅Where and how can I install twitter's Python API?。
另外,如果出现进一步的错误,请参阅ImportError: No module named tweepy
相关问题 更多 >
编程相关推荐