i am trying to do a Sentiment analysis using AWS as explained in the following section http://docs.aws.amazon.com/gettingstarted/latest/emr/getting-started-emr-sentiment-tutorial.html
我正在尝试使用AWS进行情感分析,如以下部分所述http://docs.aws.amazon.com/gettingstarted/latest/emr/getting-started-emr-sentiment-tutorial.html
Everything went fine until I encountered the following error [ec2-user@ip-10-65-140-113 sentiment]$ ls enter code herecollector.py twaiter.py twaiter.pyc twitterparams.py
一切顺利,直到我遇到以下错误[ec2-user @ ip-10-65-140-113情绪] $ ls输入代码herecollector.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**
Any help as to why this could be. twaiter.py has the following content. I opened the twaiter.py to see line no 5 and is here
任何帮助,为什么这可能是。 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.
@
1 个解决方案
#1
The message "ImportError: No module named tweepy" clearly shows that the ec2 machine does not have tweepy library installed. So while running the current python script, it is not able to locate it and therefore giving import error.
消息“ImportError:No module named tweepy”清楚地表明ec2机器没有安装tweepy库。因此,在运行当前的python脚本时,它无法找到它并因此导致导入错误。
There are several ways to install tweepy. One simple way in Linux machine is
sudo pip install tweepy
有几种方法可以安装tweepy。在Linux机器中的一个简单方法是sudo pip install tweepy
Other ways are:
其他方式是:
http://code.google.com/p/tweepy/
You can get to a tutorial wiki page for it at the same Google Code link.
您可以在同一Google代码链接*问教程维基页面。
To install it with easy_install, just run easy_install tweepy
要使用easy_install安装它,只需运行easy_install tweepy即可
To install it with git:
要用git安装它:
git clone git://github.com/joshthecoder/tweepy.git
cd tweepy
python setup.py install
To install it from source, download the source from http://pypi.python.org/pypi/tweepy then run something like:
git clone git://github.com/joshthecoder/tweepy.git cd tweepy python setup.py install要从源代码安装它,请从http://pypi.python.org/pypi/tweepy下载源代码,然后执行以下命令:
tar xzvf tweepy-1.7.1.tar.gz
cd tweepy-1.7.1
python setup.py install
tar xzvf tweepy-1.7.1.tar.gz cd tweepy-1.7.1 python setup.py install
Please refer Where and how can I install twitter's Python API? for further details.
请参考我在哪里以及如何安装twitter的Python API?了解更多详情。
Also, if further error comes refer ImportError: No module named tweepy
此外,如果还有其他错误,请参阅ImportError:没有名为tweepy的模块
#1
The message "ImportError: No module named tweepy" clearly shows that the ec2 machine does not have tweepy library installed. So while running the current python script, it is not able to locate it and therefore giving import error.
消息“ImportError:No module named tweepy”清楚地表明ec2机器没有安装tweepy库。因此,在运行当前的python脚本时,它无法找到它并因此导致导入错误。
There are several ways to install tweepy. One simple way in Linux machine is
sudo pip install tweepy
有几种方法可以安装tweepy。在Linux机器中的一个简单方法是sudo pip install tweepy
Other ways are:
其他方式是:
http://code.google.com/p/tweepy/
You can get to a tutorial wiki page for it at the same Google Code link.
您可以在同一Google代码链接*问教程维基页面。
To install it with easy_install, just run easy_install tweepy
要使用easy_install安装它,只需运行easy_install tweepy即可
To install it with git:
要用git安装它:
git clone git://github.com/joshthecoder/tweepy.git
cd tweepy
python setup.py install
To install it from source, download the source from http://pypi.python.org/pypi/tweepy then run something like:
git clone git://github.com/joshthecoder/tweepy.git cd tweepy python setup.py install要从源代码安装它,请从http://pypi.python.org/pypi/tweepy下载源代码,然后执行以下命令:
tar xzvf tweepy-1.7.1.tar.gz
cd tweepy-1.7.1
python setup.py install
tar xzvf tweepy-1.7.1.tar.gz cd tweepy-1.7.1 python setup.py install
Please refer Where and how can I install twitter's Python API? for further details.
请参考我在哪里以及如何安装twitter的Python API?了解更多详情。
Also, if further error comes refer ImportError: No module named tweepy
此外,如果还有其他错误,请参阅ImportError:没有名为tweepy的模块