Skip to content

Error Installing Python Docker Module in Managed Environment #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MAVRICK-1 opened this issue Jan 27, 2025 · 1 comment · Fixed by #19 · May be fixed by #18
Closed

Error Installing Python Docker Module in Managed Environment #17

MAVRICK-1 opened this issue Jan 27, 2025 · 1 comment · Fixed by #19 · May be fixed by #18

Comments

@MAVRICK-1
Copy link

MAVRICK-1 commented Jan 27, 2025

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:

Image

Steps to Reproduce:

  1. Run the make aether-gnbsim-install command as shown in the logs.
  2. 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 use pipx 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

@gab-arrobo
Copy link
Contributor

Hi @MAVRICK-1, just to confirm, do you see this issue with Ubuntu 24.04? or do you see this issue with other Ubuntu versions, as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants