[英]How do you add httplib2 into ansible?
I am trying to use the get_url module for ansible and when I run it I get the following error: 我试图将get_url模块用于ansible ,当我运行它时,出现以下错误:
failed: [localhost] => (item=10) => {"failed": true, "item": "10"}
msg: httplib2 is not installed
Now I have successfully installed httplib2 using pip: 现在,我已经使用pip成功安装了httplib2:
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).
我可以看到,ansible正在使用与操作系统(已安装httplib2的操作系统)不同的PYTHON_PATH,但是我无法确定如何将httplib2安装到该路径中(除了复制它不是很好)。
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: 我在其中一台Mac电脑上遇到了这个问题(最近我一直在Homebrew Python安装和系统安装之间进行切换,所以无论如何都是时髦的),最终至少在特定的会话中进行了修复,最终导致了问题。在CLI上进行交互式python会话并导入库:
$ 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. 如果这是一个ansible-playbook错误,则可以运行pip命令来安装httplib2工件。 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. 了解如何安装Ansible以及Ansible在哪里使用Python安装。 Explorer your hard disk with your file manager.
使用文件管理器浏览硬盘。
Use pip
command from this particular Python installation (usually in bin
directory) to install httplib2
. 使用此特定Python安装中的
pip
命令(通常在bin
目录中)安装httplib2
。 This way httplib2 ends up to the right Python installation. 这样,httplib2最终可以正确安装Python。
Furthermore to find out what Python command Ansible is using do: 此外,要找出Ansible使用的Python命令可以执行以下操作:
which ansible
Shows you full path to the ansible executable. 向您显示ansible可执行文件的完整路径。 And then:
然后:
head /where/is/my/ansible/command
It prints you the script header which should include full path to python
command. 它会打印出脚本标头,其中应包含
python
命令的完整路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.