使用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
答案 0 :(得分:0)
/ usr / bin / python可能是python 2.x,而不是python3。正如上面Chuck所指出的,将解释器更改为python3应该可以解决问题。