[Python] Getting 'Could not install packages due to an OSError' when installing Python...

Discussão em 'Python' iniciado por Stack, Maio 6, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to install a few pip packages in a GitLab pipeline job in order to run a Python script. The image used to run the pipeline job is a custom Python image using Python version 3.12 and with Ubuntu 25.04 and is set to a non-root user python. When the pipeline job runs I have a command to active the Python virtual environment then I install the packages. I get an error when trying to run the pip install command.

    This is the job output where the error occurs:

    $ source /home/python/venv/bin/activate # collapsed multi-line command
    /home/python/venv/bin/python
    Collecting openpyxl
    Downloading openpyxl-3.1.5-py2.py3-none-any.whl.metadata (2.5 kB)
    Collecting python-dateutil
    Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl.metadata (8.4 kB)
    Collecting et-xmlfile (from openpyxl)
    Downloading et_xmlfile-2.0.0-py3-none-any.whl.metadata (2.7 kB)
    Collecting six>=1.5 (from python-dateutil)
    Downloading six-1.17.0-py2.py3-none-any.whl.metadata (1.7 kB)
    Downloading openpyxl-3.1.5-py2.py3-none-any.whl (250 kB)
    Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
    Downloading six-1.17.0-py2.py3-none-any.whl (11 kB)
    Downloading et_xmlfile-2.0.0-py3-none-any.whl (18 kB)
    Installing collected packages: six, et-xmlfile, python-dateutil, openpyxl
    ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/home/python/venv/lib/python3.13/site-packages/six.py'
    Check the permissions.


    I've tried adding the --user flag to the pip install command but then I get a different error: ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.

    I think the permissions error has to do with the Python image is not running as root. I can't figure out how to give the user python enough permissions to install the pip packages. Any help would be appreciated.

    Continue reading...

Compartilhe esta Página