python安装pylad报错_即使安装它,Ansible也不能导入docker-py

I checked this post and followed the fix in both answers and neither worked. I'm opening a new post partly because of that and partly because I'm getting a slightly different error even though the problem might be the same.

Ansible host:

$ ansible --version

ansible 2.1.0.0

config file = /etc/ansible/ansible.cfg

configured module search path = Default w/o overrides

Destination client myserver:

$ pip list | egrep 'six|docker|websocket_client'

docker-py (1.2.3)

six (1.10.0)

test.yml:

---

- hosts: myserver

remote_user: root

tasks:

- name: stop any running docker registries

docker_container:

name: registry

state: stopped

...

Ansible server (ansible-playbook aliased to ap):

$ ap -vvvv test.yml

The output:

(probably extraneous output, snipped):

fatal: [myserver]: FAILED! => {

"changed": false,

"failed": true,

"invocation": {

"module_args": {

"api_version": null,

"blkio_weight": null,

"cacert_path": null,

"capabilities": null,

"cert_path": null,

"command": null,

"cpu_period": null,

"cpu_quota": null,

"cpu_shares": null,

"cpuset_cpus": null,

"cpuset_mems": null,

"debug": false,

"detach": true,

"devices": null,

"dns_opts": null,

"dns_search_domains": null,

"dns_servers": null,

"docker_host": null,

"entrypoint": null,

"env": null,

"etc_hosts": null,

"exposed_ports": null,

"filter_logger": false,

"force_kill": false,

"groups": null,

"hostname": null,

"image": null,

"interactive": false,

"ipc_mode": null,

"keep_volumes": true,

"kernel_memory": null,

"key_path": null,

"kill_signal": null,

"labels": null,

"links": null,

"log_driver":

"json-file",

"log_options": null,

"mac_address": null,

"memory": "0",

"memory_reservation": null,

"memory_swap": null,

"memory_swappiness": null,

"name": "registry",

"network_mode": null,

"networks": null,

"oom_killer": null,

"paused": false,

"pid_mode": null,

"privileged": false,

"published_ports": null,

"pull": false,

"read_only": false,

"recreate": false,

"restart": false,

"restart_policy": null,

"restart_retries": 0,

"security_opts": null,

"shm_size": null,

"ssl_version": null,

"state": "stopped",

"stop_signal": null,

"stop_timeout": null,

"timeout": null,

"tls": null,

"tls_hostname": null,

"tls_verify": null,

"trust_image_content": false,

"tty": false,

"ulimits": null,

"user": null,

"uts": null,

"volume_driver": null,

"volumes": null,

"volumes_from": null

},

"module_name": "docker_container"

},

"msg":

(the pertinent error):

"Failed to import docker-py - cannot import name NotFound. Try pip install docker-py"}

I get the same error when I downgrade the docker-py module to 1.1.0 as per the first answer in the referenced post. I also tried to chmod the directories and it made no difference:

(/usr/lib/python2.7/site-packages) myserver$ ls -lad docker*

drwxr-xr-x. 6 root root 4096 Jul 4 10:57 docker/

drwxr-xr-x. 2 root root 4096 Jul 4 10:57 docker_py-1.2.3-py2.7.egg-info/

from chmod -R go+rx docker*.

Has anyone seen this before? I have tried using the pip ansible module to install the modules and then after removing them manually, reinstalled them manually as in the referenced post. I'm also using 2.1.0.0. as you can see, which was supposed to fix this issue.

解决方案

This is because new versions of python modules docker and docker-py that ansible uses are incompatible. I had to revert back and explicitly specify the following versions of PIP packages:

docker: 2.0.0

docker-py: 1.10.6

Sample playbook task for these:

- name: install certain python modules for docker

pip:

name: "{{ item.name }}"

version: "{{ item.version }}"

state: present

with_items:

- { name: docker, version: 2.0.0 }

- { name: docker-py, version: 1.10.6 }

All my play books work fine since then.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值