-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Title: Error Installing Python Docker Module in Managed Environment
Description:
The installation process fails during the install docker module for Python
task due to the error externally-managed-environment
. This occurs because the Python environment is marked as externally managed, and direct installations using pip
are restricted without using a virtual environment or passing the --break-system-packages
flag.
Error Output:
Steps to Reproduce:
- Run the
make aether-gnbsim-install
command as shown in the logs. - Observe the failure during the
install docker module for Python
task.
Expected Behavior:
The playbook should successfully install the Python docker
module without errors.
Actual Behavior:
The task fails with a fatal error, indicating that the Python environment is externally managed.
Solution:
The issue was resolved by creating a Python virtual environment and installing the docker
module within it. Here is the updated install.yml
playbook snippet:
- name: Create a virtual environment for Python
ansible.builtin.command:
cmd: python3 -m venv /opt/dockerenv
when: inventory_hostname in groups['gnbsim_nodes']
become: true
- name: Install docker module for Python in virtual environment
pip:
name: docker
virtualenv: /opt/dockerenv
when: inventory_hostname in groups['gnbsim_nodes']
become: true
Key Notes:
- Using a virtual environment isolates the Python dependencies and avoids conflicts with the system-wide package manager.
- This approach complies with the
externally-managed-environment
restriction in modern Python distributions. - No need to override the restriction (
--break-system-packages
) or usepipx
as additional tools.
Environment:
- OS: Ubuntu (specific version can be added)
- Python Version: Python 3.12
- Ansible Version: Provide the version used
- Playbook File:
install.yml
Additional Updates:
The remaining tasks (such as pulling the Docker image and setting up user permissions) worked as expected without further modifications.
@llpeterson I have already solve this issue rasing a PR for this