Using Ubuntu 18.04, Ansible 2.9, Python 3.6.9, have installed python3-apt
On a basic ansible command ansible -b all -m apt -a "name=apache2 state=latest"
Get Error:
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
Go to python3 dist-package directory
cd /usr/lib/python3/dist-packages
And then link these two files
sudo ln -s apt_inst.cpython-35m-x86_64-linux-gnu.so apt_inst.so
sudo ln -s apt_pkg.cpython-35m-x86_64-linux-gnu.so apt_pkg.so
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With