Search code examples
amazon-ec2emrbootstrappingmrjob

Amazon EMR + mrjob: bootstrap error, "bootstrap action 1 returned a non-zero return code"


I am trying to run an mrjob on Amazon's EMR using ec2 instances. It was working until I realized I was using python packages (mechanize, BeautifulSoup, boto). So, I added to my mrjob.conf file, but now I keep getting this error:

No handlers could be found for logger "mrjob.emr"
Traceback (most recent call last):
  File "run_job.py", line 102, in <module>
    run()
  File "run_job.py", line 76, in run
    runner.run()
  File "C:\Program Files (x86)\Python278\lib\site-packages\mrjob\runner.py", line 464, in run
    self._run()
  File "C:\Program Files (x86)\Python278\lib\site-packages\mrjob\emr.py", line 821, in _run
    self._wait_for_job_to_complete()
  File "C:\Program Files (x86)\Python278\lib\site-packages\mrjob\emr.py", line 1689, in _wait_for_jo
b_to_complete
    raise Exception(msg)
Exception: Job on job flow j-CZDG75Z1X58 failed with status FAILED: On the master instance (i-0ef8bb
cc), bootstrap action 1 returned a non-zero return code

I'm at my wits end here, I've been trying to solve this for quite a while now and I can't seem to get it. Here is the conf file:

runners:
  emr:
    bootstrap_mrjob: True
    ami_version: 2.4.11

    bootstrap:
        - sudo apt-get install -y python-pip
        - sudo pip install mechanize
        - sudo pip install bs4
        - sudo pip install mrjob
        - sudo pip install boto

    aws_access_key_id: xxxx
    aws_region: xxxx
    aws_secret_access_key: xxxx
    num_ec2_core_instances: 1
    ec2_core_instance_type: m1.small
    iam_instance_profile: xxxx

Solution

  • Figured it out finally!

    in mrjob.conf, i changed the bootstrap: and all of its elements to

    bootstrap_cmds:
        - sudo easy_install pip
        - sudo easy_install mechanize
        - sudo easy_install boto
        - sudo easy_install BeautifulSoup4
    

    turns out mjrob almost always automatically installs its own package to the ec2 instances. So I didnt need to have that in the bootstrap at all.

    Now it runs like a charm! :)