ansible 返回“无法导入所需的 Python 库(Python 的 Docker SDK:docker (Python >= 2.7) 或 docker-py (Python 2.6)) [英] ansible returns with "Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6))

查看:21
本文介绍了ansible 返回“无法导入所需的 Python 库(Python 的 Docker SDK:docker (Python >= 2.7) 或 docker-py (Python 2.6))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 ubuntu 中运行我的服务器:

I am running myserver in ubuntu:

+ sudo cat /etc/os-release
NAME="Ubuntu"
VERSION="16.04.6 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.6 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial

我使用 ansible,运行时出现以下错误:

I use ansible and when I run it I get the following error:

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on dd63315fad06's Python /usr/bin/python. Please read module documentation and install in the appropriate location, for example via `pip install docker` or `pip install docker-py` (Python 2.6). The error was: No module named docker"}

当我跑步时

python -c "import sys; print(sys.path)"

我明白了:

['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/local/lib/python2.7/dist-packages/pip-19.2.2-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/fasteners-0.15-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/monotonic-1.5-py2.7.egg', '/usr/lib/python2.7/dist-packages']

和python版本如下:

and python versions are as follows:

+ python --version
Python 2.7.12
+ python3 --version
Python 3.5.2

然后当我看到一切都很好,我不知道为什么我得到

Then as I see everything is fine and I am not sure why I get

"Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on dd63315fad06's Python /usr/bin/python. Please read module documentation and install in the appropriate location, for example via `pip install docker` or `pip install docker-py` (Python 2.6). The error was: No module named docker"

在 Ansible 中?

in ansible?

推荐答案

您似乎没有安装 docker 模块.

It appears that you don't have the docker module installed.

您需要通过系统包管理器(例如apt install python-docker)或使用pip(pip install docker).

You will need to install it via your system package manager (apt install python-docker, for example), or using pip (pip install docker).

如果您有多个 Python 版本,请确保您已将 docker 模块安装到 Ansible 正在使用的版本中.

If you have multiple Python versions, make sure that you've installed the docker module into the version that Ansible is using.

这篇关于ansible 返回“无法导入所需的 Python 库(Python 的 Docker SDK:docker (Python >= 2.7) 或 docker-py (Python 2.6))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆