使用 Ubuntu 18.04
, Ansible 2.9, Python 3.6.9
,已安装 python3-apt
在基本的 ansible 命令上 ansible -b all -m apt -a "name=apache2 state=latest"
获取错误:
FAILED! => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"msg": "Could not import python modules: apt, apt_pkg. Please install python3-apt package."
}
$ sudo apt-get install python3-apt
$ ansible --version
ansible 2.9.12
python version = 3.6.9
$ python --version
Python 3.7.6
原文由 Sam-T 发布,翻译遵循 CC BY-SA 4.0 许可协议
转到 python3 dist-package 目录
cd /usr/lib/python3/dist-packages
然后链接这两个文件