I am trying to use the get_url module for ansible and when I run it I get the following error:
failed: [localhost] => (item=10) => {"failed": true, "item": "10"}
msg: httplib2 is not installed
Now I have successfully installed httplib2 using pip:
pip install httplib2
Requirement already satisfied (use --upgrade to upgrade): httplib2 in /usr/local/lib/python2.7/site-packages
But obviously that hasn't helped the situation. I can see that ansible is using a different PYTHON_PATH than the OS (where httplib2 is installed) but I cannot work out how to get a httplib2 installed into that path (other than copying it which isn't nice).
Any help greatly appreciate.
I ran into this problem on one of my Macs (I had been switching between a Homebrew Python installation and the system install recently, so something was funky anyways), and what ended up fixing it, at least for a particular session, was starting an interactive python session on the CLI and importing the library:
$ python
>>> import httplib2
>>> exit()
$ [continue what you were doing with ansible...]
If this is an ansible-playbook error, you can run a pip command to install the httplib2 artifact. Try running the following task before:
tasks:
- name: pip httplib2
# ansible uri module requires httplib2
pip: name=httplib2 extra_args="--user"
Find out how did you install Ansible and where is the Python installation Ansible is using. Explorer your hard disk with your file manager.
Use pip
command from this particular Python installation (usually in bin
directory) to install httplib2
. This way httplib2 ends up to the right Python installation.
Furthermore to find out what Python command Ansible is using do:
which ansible
Shows you full path to the ansible executable. And then:
head /where/is/my/ansible/command
It prints you the script header which should include full path to python
command.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.