Install lxml for community.general.xml

I am running Ansible on Ubuntu 20.04.

I’d like to use the community.general.xml module.

I get a “ModuleNotFoundError” relating to lxml when I try to run the playbook.

I tried sudo apt-get install python3-lxml

There were errors toward the end of the process:


Setting up ansible (5.2.0-1ppa~focal) …
Killed
Traceback (most recent call last):
File “/usr/bin/py3compile”, line 290, in
main()
File “/usr/bin/py3compile”, line 269, in main
compile(files, versions,
File “/usr/bin/py3compile”, line 187, in compile
pipe.send(fn)
File “/usr/bin/py3compile”, line 138, in py_compile
stdin.write(filename.encode(‘utf-8’) + b’\n’)
BrokenPipeError: [Errno 32] Broken pipe
dpkg: error processing package ansible (–configure):
installed ansible package post-installation script subprocess returned error exit status 1
Setting up python3-soupsieve (1.9.5+dfsg-1) …
Setting up python3-bs4 (4.8.2-1) …
Setting up python3-lxml:arm64 (4.5.0-1ubuntu0.5) …
Processing triggers for libc-bin (2.31-0ubuntu9.2) …
Errors were encountered while processing:
ansible
E: Sub-process /usr/bin/dpkg returned an error code (1)

…and I still get the same error when running the playbook.

Note (in case this matters): when I run ansible --version, I get:

ansible [core 2.12.1]
config file = /etc/ansible/ansible.cfg
configured module search path = [‘/home/ubuntu/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python3/dist-packages/ansible
ansible collection location = /home/ubuntu/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]
jinja version = 2.10.1
libyaml = True

Jason