Reputation: 2101
System: Mac OSX 10.6.5, Python 2.6
I try to run the python script below:
from mrjob.job import MRJob
class MRWordCounter(MRJob):
def mapper(self, key, line):
for word in line.split():
yield word, 1
def reducer(self, word, occurrences):
yield word, sum(occurrences)
if __name__ == '__main__':
MRWordCounter.run()
I get the following error:
:~ vskarich$ python mrjob_test.py < words
Traceback (most recent call last):
File "mrjob_test.py", line 1, in <module>
from mrjob.job import MRJob
ImportError: No module named mrjob.job
I had used easy_install like so:
sudo easy_install mrjob
This command downloaded the needed .egg file, and my site-packages directory for python looks like this:
:~ vskarich$ cd /Library/Python/2.6/site-packages
:site-packages vskarich$ ls
PyYAML-3.09-py2.6-macosx-10.6-universal.egg
easy-install.pth
README
mrjob-0.2.0-py2.6.egg
boto-2.0b3-py2.6.egg
simplejson-2.1.2-py2.6-macosx-10.6-universal.egg
I am not sure what to do here as I am somewhat new to python; any help would be much appreciated. Thank you!
Upvotes: 5
Views: 12735
Reputation: 13
mrjob package can be installed by running following command:
pip install mrjob
After installation, the error will be solved.
It worked in my case.
Upvotes: 0
Reputation: 56
I had the same problem, I tried pip install mrjob
, sudo easy_install mrjob
. It looked like it installed successfully, but when I ran a simple example script, I got the import error.
I got it to work by following the instructions at: http://pythonhosted.org//mrjob/guides/quickstart.html#installation.
In a nutshell, I cloned the source code from github and ran python setup.py install
. My problem might be different from yours, though. There was nothing in my site-packages directory for mrjob after running pip-install and easy_install.
Upvotes: 2
Reputation: 85125
Two suggestions:
Make sure you don't have any file or directory permissions problems for the installed eggs and files in the site-packages
directory.
If you have installed another instance of Python 2.6 (besides the Apple-supplied one in /usr/bin/python2.6
), make sure you have installed a separate version of easy_install
for it. As is, your output indicates it was almost certainly installed using the Apple-supplied easy_install
in /usr/bin
which is for the Apple-supplied Python. The easiest way to do that is to install the Distribute package using the new Python.
Upvotes: 2