Python module import error "ImportError: no module named mrjob.job"

System: Mac OSX 10.6.5, Python 2.6

I am trying to run a 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 used easy_install as follows:

sudo easy_install mrjob

This command downloaded the necessary .egg file, and the directory of my python package site 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'm not sure what to do here since I'm a little new to python; Any help is appreciated. Thank!

+3
source share
2 answers

Two suggestions:

  • Make sure that the installed files and files in the directory do site-packagesnot have any problems with the files or directories.

  • Python 2.6 ( Apple /usr/bin/python2.6), , easy_install. , Apple easy_install /usr/bin, Apple Python. - Distribute Python.

+2

, pip install mrjob, sudo easy_install mrjob. , , script, .

, : http://pythonhosted.org//mrjob/guides/quickstart.html#installation.

, github python setup.py install. . - mrjob , pip-install easy_install.

+1

Source: https://habr.com/ru/post/1775314/


All Articles