linuxserver / docker-mods

Documentation and Examples of base container modifications
GNU General Public License v3.0
1.02k stars 265 forks source link

Pillow installation need install option --break-system-packages #848

Closed Koky05 closed 5 months ago

Koky05 commented 6 months ago

Is there an existing issue for this?

Name of mod

universal-package-install

Name of base container

orcaslicer

Current Behavior

I try to install python3 and Pillow for OrcaSlicer via mods:

DOCKER_MODS: linuxserver/mods:code-server-python3|linuxserver/mods:universal-package-install
  INSTALL_PIP_PACKAGES: Pillow

But it fails to install:

[mod-init] **** Installing all pip packages ****
WARNING: The directory '/config/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to

    install.

    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.

    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.

    See /usr/share/doc/python3.11/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
WARNING: The directory '/config/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to

    install.

    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.

    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.

    See /usr/share/doc/python3.11/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

Expected Behavior

If I try to install directly with command pip install Pillow --break-system-packages it works. My python code use from PIL import Image.

Steps To Reproduce

  1. Run docker-compose up -d

Environment

- OS:
- How docker service was installed:

CPU architecture

x86-64

Docker creation

version: "3.9"
services:
  orcaslicer:
    image: lscr.io/linuxserver/orcaslicer
    container_name: Orca-Slicer
    network_mode: host
    hostname: orcaslicer
    privileged: true
    healthcheck:
      test: curl -f http://${ORCA_USER}:${ORCA_PASSWORD}@localhost:3000/ || exit 1
    volumes:
      - /volume1/docker/orcaslicer:/config:rw
      - /volume1/docker/orcaslicer/data:/var/lib/docker
      - /var/run/docker.sock:/var/run/docker.sock
      - /volume1/USB/GCode:/gcode
      - /volume1/USB/3D Models:/3dmodel
    devices:
      - /dev/dri:/dev/dri
    environment:
      TZ: Europe/Bratislava
      PUID: 0
      PGID: 0
      TITLE: Orca-Slicer
      CUSTOM_USER: ${ORCA_USER}
      PASSWORD: ${ORCA_PASSWORD}
      CUSTOM_PORT: 3006
      CUSTOM_HTTPS_PORT: 3007
      LC_ALL: sk_SK.UTF-8
      NO_DECOR: true
      DOCKER_MODS: linuxserver/mods:code-server-python3|linuxserver/mods:universal-package-install
      INSTALL_PIP_PACKAGES: Pillow
    user: 0:0
    cap_add:
      - NET_ADMIN
      - NET_RAW
      - SYS_ADMIN
      - SYS_MODULE
    labels:
      - com.centurylinklabs.watchtower.enable=true
    restart: unless-stopped
networks:
  doc_bridge:
    external: true

Container logs

[mod-init] **** Installing all pip packages ****
WARNING: The directory '/config/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to

    install.

    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.

    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.

    See /usr/share/doc/python3.11/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
WARNING: The directory '/config/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to

    install.

    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.

    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.

    See /usr/share/doc/python3.11/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
LinuxServer-CI commented 5 months ago

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

aptalca commented 5 months ago

Our universal mods currently support the alpine and ubuntu baseimages but orcaslicer is debian based.

thespad commented 5 months ago

The mod logic will handle Debian and it should broadly work where Ubuntu does but the Orcaslicer image doesn't setup a venv and the Kasm base installs python, so the pip install will break because of the Python system management changes in PEP 668. If there's a Debian repo package for Pillow you can install, that would work, but otherwise it would need changes to the image itself to change how it handles Python.

aptalca commented 5 months ago

For now you can set these env vars while we look into adding compatibility:

DOCKER_MODS=linuxserver/mods:universal-package-install
INSTALL_PIP_PACKAGES=Pillow
INSTALL_PACKAGES=python3-venv
CREATE_VENV=true
Koky05 commented 5 months ago

Thanks I try it and it works for now.