Installation failure of Ansible playbook due to deprecated lib2to3 module
ModuleNotFound error during playbook run
After updating to the latest Galaxy release (v24.2, galaxy_commit_id: release_24.2) in the ./galaxy/group_vars/galaxyservers.yml config file, the Galaxy Admin tutorial playbook (Revision: 102, Last modified: Apr 8, 2025) deployment fails on Ubuntu 24.04 LTS with the following error:
TASK [galaxyproject.galaxy : Get current Galaxy DB version] *****************************************************
fatal: [localhost]: FAILED! => changed=false
cmd:
- /srv/galaxy/venv/bin/python
- /srv/galaxy/server/scripts/manage_db.py
- -c
- /srv/galaxy/config/galaxy.yml
- db_version
delta: '0:00:00.765326'
end: '2025-04-25 18:07:44.262573'
failed_when_result: true
msg: non-zero return code
rc: 1
start: '2025-04-25 18:07:43.497247'
stderr: |-
Traceback (most recent call last):
File "/srv/galaxy/server/scripts/manage_db.py", line 12, in <module>
from galaxy.model.migrations.scripts import LegacyManageDb
File "/srv/galaxy/server/lib/galaxy/model/__init__.py", line 146, in <module>
from galaxy.files.templates import (
File "/srv/galaxy/server/lib/galaxy/files/__init__.py", line 16, in <module>
from galaxy.files.sources import (
File "/srv/galaxy/server/lib/galaxy/files/sources/__init__.py", line 37, in <module>
from galaxy.util.template import fill_template
File "/srv/galaxy/server/lib/galaxy/util/template.py", line 28, in <module>
from lib2to3.refactor import RefactoringTool
ModuleNotFoundError: No module named 'lib2to3'
stderr_lines: <omitted>
stdout: ''
stdout_lines: <omitted>
ModuleNotFoundError: No module named 'lib2to3'
Workaround
After manually installing
sudo apt install python3-lib2to3
the playbook is running the deployment without further issues.
Root Cause
Ubuntu 24.04 LTS uses Python 3.12. The Python lib2to3 package is deprecated since version 3.11 and will be removed completely in version 3.13 (https://docs.python.org/3.11/library/2to3.html).
Proposed Fixes
I added a Python and platform version check to the pre-tasks section of the galaxy.yml playbook template to install the lib2to3 package if necessary. As part of the fix I also updated the role versions in requirements.yml, and adjusted the Galaxy release and Miniconda versions in group_vars/galaxyservers.yml. I will create a pull request.