pythonmodulepathmrjob

Python Module Import Error "ImportError: No module named mrjob.job"


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!


Solution

  • Two suggestions:

    1. Make sure you don't have any file or directory permissions problems for the installed eggs and files in the site-packages directory.

    2. 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.