No module named ansible.errors; cannot sudo

I’ve just added Ansible to my git codebase and am attempting to run a playbook. I’m getting the message “ImportError: No module named ansible.errors”

I cannot do sudo on my host, but supposedly ansible can run without installing and without root access. I’m not using a virtual machine, but it appears this is only recommended, not required. I am using an Ubuntu 14 box. So far as I know it is 64-bit box.

  1. I followed the instructions to git clone git://github.com/ansible/ansible.git --recursive
    (to current development version of ansible, updated on 12/23)
  2. I copied the code to my ~/library folder as required by my host.
  3. I then added ~/library/ansible/bin to my path and ran the env command to confirm it was there.
  4. I marked the files in ~/library/ansible/bin as executable by the user and group
  5. I navigated to the desired playbook’s folder. (~/library/cibox-master)
    and ran: ansible-playbook jenkinsbox.yml
  6. On line 39, I get the error No module named ansible.errors

This happens with ansible dev (2.1) and ansible 2.0.

Just in case, I backed out to ansible 1.9. When I run that version, it complains about module jinja2 being missing. No complaint about ansible.error, though.

File “/mnt/gfs/sfmtaweb/livedev/library/ansible/lib/ansible/runner/init.py”, line 32, in
import jinja2

Any ideas how to get back on track?

I’ve just added Ansible to my git codebase and am attempting to run a playbook. I’m getting the message “ImportError: No module named ansible.errors”

I cannot do sudo on my host, but supposedly ansible can run without installing and without root access. I’m not using a virtual machine, but it appears this is only recommended, not required. I am using an Ubuntu 14 box. So far as I know it is 64-bit box.

  1. I followed the instructions to git clone git://github.com/ansible/ansible.git --recursive
    (to current development version of ansible, updated on 12/23)
  2. I copied the code to my ~/library folder as required by my host.
  3. I then added ~/library/ansible/bin to my path and ran the env command to confirm it was there.

You need both the scripts and the python library from the git checkout. The error you’re getting appears to be that you’re using the git version of the scripts but finding an old version of the library.

There’s a Bourne shell file that you can source to set up both your path and the python library path (and egginfo (python library metadata)).

You can find those instructions here:
http://docs.ansible.com/ansible/intro_installation.html#running-from-source

-Toshio

I’ve just added Ansible to my git codebase and am attempting to run a playbook. I’m getting the message “ImportError: No module named ansible.errors”

I cannot do sudo on my host, but supposedly ansible can run without installing and without root access. I’m not using a virtual machine, but it appears this is only recommended, not required. I am using an Ubuntu 14 box. So far as I know it is 64-bit box.

  1. I followed the instructions to git clone git://github.com/ansible/ansible.git --recursive
    (to current development version of ansible, updated on 12/23)
  2. I copied the code to my ~/library folder as required by my host.
  3. I then added ~/library/ansible/bin to my path and ran the env command to confirm it was there.

You need both the scripts and the python library from the git checkout. The error you’re getting appears to be that you’re using the git version of the scripts but finding an old version of the library.

There’s a Bourne shell file that you can source to set up both your path and the python library path (and egginfo (python library metadata)).

You can find those instructions here:
http://docs.ansible.com/ansible/intro_installation.html#running-from-source

-Toshio

Thank you. That got me quite a bit further before I got stuck again.

  1. I marked the files in ~/library/ansible/bin as executable by the user and group
  2. I navigated to the desired playbook’s folder. (~/library/cibox-master)
    and ran: ansible-playbook jenkinsbox.yml
  3. On line 39, I get the error No module named ansible.errors

This happens with ansible dev (2.1) and ansible 2.0.

Just in case, I backed out to ansible 1.9. When I run that version, it complains about module jinja2 being missing. No complaint about ansible.error, though.

File “/mnt/gfs/sfmtaweb/livedev/library/ansible/lib/ansible/runner/init.py”, line 32, in
import jinja2

Any ideas how to get back on track?

  1. I added my path where I wanted my added Python libraries to be and further ran the env-setup file.
  2. I try to run the pip install paramiko PyYAML Jinja2 httplib2 six, pointing to the various correct paths.

Result: The install program complains at [my site path]/.local/lib/python2.7/site-packages/pkg_resources/init.py line 847:

in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The ‘pip==8.0.0.dev0’ distribution was not found and is required by the application

(I’m a little suspicious as when I commit and pull to my local computer, that line seems to be in 849.)

But https://github.com/pypa/pip has 7.1.2. Where would I get an 8.0.0. Or, if 8.0.0 doesn’t exist, how do I get the program to be happy with 7.1.2?

I’m on Python 2.7.3.

The Ansible version that I downloaded was the version current on https://github.com/ansible/ansible as of Thursday, Dec. 24.

I’m not even sure this is an Ansible question.

Here’s the full traceback that it provides. Oddly it gives this same traceback if I execute pip -V

Traceback (most recent call last):
File “[site root path]/library/usr/local/bin/pip”, line 5, in
from pkg_resources import load_entry_point
File "[user root path]/.local/lib/python2.7/site-packages/pkg_resources/init.py ", line 3138, in
@_call_aside
File "[user root path]/.local/lib/python2.7/site-packages/pkg_resources/init.py ", line 3124, in _call_aside
f(*args, **kwargs)
File "/[user root path]/.local/lib/python2.7/site-packages/pkg_resources/init.py ", line 3151, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "[user root path]/.local/lib/python2.7/site-packages/pkg_resources/init.py ", line 663, in _build_master
return cls._build_from_requirements(requires)
File "[user root path]/.local/lib/python2.7/site-packages/pkg_resources/init.py ", line 676, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "[user root path]/.local/lib/python2.7/site-packages/pkg_resources/init.py ", line 849, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The ‘pip==8.0.0.dev0’ distribution was not f ound and is required by the application

Thank you again for any insight you can provide.

Charles Belov
SFMTA Webmaster
https://www.sfmta.com

  1. I added my path where I wanted my added Python libraries to be and further ran the env-setup file.
  2. I try to run the pip install paramiko PyYAML Jinja2 httplib2 six, pointing to the various correct paths.

Result: The install program complains at [my site path]/.local/lib/python2.7/site-packages/pkg_resources/init.py line 847:

in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The ‘pip==8.0.0.dev0’ distribution was not found and is required by the application

(I’m a little suspicious as when I commit and pull to my local computer, that line seems to be in 849.)

But https://github.com/pypa/pip has 7.1.2. Where would I get an 8.0.0. Or, if 8.0.0 doesn’t exist, how do I get the program to be happy with 7.1.2?

I’m on Python 2.7.3.

The Ansible version that I downloaded was the version current on https://github.com/ansible/ansible as of Thursday, Dec. 24.

I’m not even sure this is an Ansible question.

Yeah, it’s not an ansible problem at this point. It sounds like there’s a mismatch between the pip version that you’re invoking by typing pip install and the pip library that script is finding. My guess is that
“[site root path]/library/usr/local/bin/pip” is the part that’s asking for pip 0.8dev. I’m not sure from your description how it got there or where the library version that corresponds with it might be. You might be able to get out of your jam by editing “[site root path]/library/usr/local/bin/pip” to not request a specific version of pip but it’s also possible that there’s a lot of other libraries that aren’t being found with your current configuration on your system which will cause further problems.

-Toshio