[Python] How to modify a container image that has a flaw without root access?

Discussão em 'Python' iniciado por Stack, Junho 13, 2025.

  1. Stack

    Stack Membro Participativo

    Environment:

    Python 3.10.12

    pip list result:

    Package Version
    ------------------ ------------------
    astunparse 1.6.3
    attrs 25.3.0
    certifi 2025.4.26
    charset-normalizer 3.4.2
    Cython 3.1.0
    exceptiongroup 1.3.0
    expecttest 0.3.0
    filelock 3.18.0
    fsspec 2025.3.2
    hypothesis 6.131.16
    idna 3.10
    Jinja2 3.1.6
    MarkupSafe 3.0.2
    mpmath 1.3.0
    networkx 3.4.2
    numpy 1.26.4
    optree 0.15.0
    packaging 25.0
    pip 25.1.1
    psutil 7.0.0
    PyYAML 6.0.2
    requests 2.32.3
    setuptools 80.4.0
    six 1.17.0
    sortedcontainers 2.4.0
    sympy 1.13.1
    torch 2.5.0a0+git81e7e0d
    torch_nnpa 1.2.0+git9bd477a
    types-dataclasses 0.6.6
    typing_extensions 4.13.2
    urllib3 2.4.0
    wheel 0.45.1


    Using podman to manage containers. I am trying to run an image that has not been created by me but has a flaw. It is a Pytorch container and there’s a model example supplied with two Python scripts. The first one is used to train the model and has some packages already installed. The problem is that when I try to run it, there’s an import failing for sklearn. When I try to install it or scikit-learn, it fails with this log:

    ../meson.build:80:0: ERROR: Unknown compiler(s): [['gfortran'], ['flang-new'], ['flang'], ['nvfortran'], ['pgfortran'], ['ifort'], ['ifx'], ['g95']]
    The following exception(s) were encountered:
    Running `gfortran --help` gave "[Errno 2] No such file or directory: 'gfortran'"
    Running `gfortran --version` gave "[Errno 2] No such file or directory: 'gfortran'"
    Running `gfortran -V` gave "[Errno 2] No such file or directory: 'gfortran'"
    Running `flang-new --help` gave "[Errno 2] No such file or directory: 'flang-new'"
    Running `flang-new --version` gave "[Errno 2] No such file or directory: 'flang-new'"
    Running `flang-new -V` gave "[Errno 2] No such file or directory: 'flang-new'"
    Running `flang --help` gave "[Errno 2] No such file or directory: 'flang'"
    Running `flang --version` gave "[Errno 2] No such file or directory: 'flang'"
    Running `flang -V` gave "[Errno 2] No such file or directory: 'flang'"
    Running `nvfortran --help` gave "[Errno 2] No such file or directory: 'nvfortran'"
    Running `nvfortran --version` gave "[Errno 2] No such file or directory: 'nvfortran'"
    Running `nvfortran -V` gave "[Errno 2] No such file or directory: 'nvfortran'"
    Running `pgfortran --help` gave "[Errno 2] No such file or directory: 'pgfortran'"
    Running `pgfortran --version` gave "[Errno 2] No such file or directory: 'pgfortran'"
    Running `pgfortran -V` gave "[Errno 2] No such file or directory: 'pgfortran'"
    Running `ifort --help` gave "[Errno 2] No such file or directory: 'ifort'"
    Running `ifort --version` gave "[Errno 2] No such file or directory: 'ifort'"
    Running `ifort -V` gave "[Errno 2] No such file or directory: 'ifort'"
    Running `ifx --help` gave "[Errno 2] No such file or directory: 'ifx'"
    Running `ifx --version` gave "[Errno 2] No such file or directory: 'ifx'"
    Running `ifx -V` gave "[Errno 2] No such file or directory: 'ifx'"
    Running `g95 --help` gave "[Errno 2] No such file or directory: 'g95'"
    Running `g95 --version` gave "[Errno 2] No such file or directory: 'g95'"
    Running `g95 -V` gave "[Errno 2] No such file or directory: 'g95’"


    Since I am not root, I cant’t install these compilers. On the other hand, I’ve tried to install binaries but it is also failing, I guess because of failing dependencies.

    pip install sklearn
    Defaulting to user installation because normal site-packages is not writeable
    Collecting sklearn
    Downloading sklearn-0.0.post12.tar.gz (2.6 kB)
    Preparing metadata (setup.py) ... error
    error: subprocess-exited-with-error

    × python setup.py egg_info did not run successfully.
    │ exit code: 1
    ╰─> [15 lines of output]
    The 'sklearn' PyPI package is deprecated, use 'scikit-learn'
    rather than 'sklearn' for pip commands.

    Here is how to fix this error in the main use cases:
    - use 'pip install scikit-learn' rather than 'pip install sklearn'
    - replace 'sklearn' by 'scikit-learn' in your pip requirements files
    (requirements.txt, setup.py, setup.cfg, Pipfile, etc ...)
    - if the 'sklearn' package is used by one of your dependencies,
    it would be great if you take some time to track which package uses
    'sklearn' instead of 'scikit-learn' and report it to their issue tracker
    - as a last resort, set the environment variable
    SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True to avoid this error

    More information is available at
    https://github.com/scikit-learn/sklearn-pypi-package
    [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip.
    error: metadata-generation-failed

    × Encountered error while generating package metadata.
    ╰─> See above for output.


    So, the question is how can I overcome this?

    Continue reading...

Compartilhe esta Página