I encounter an error when trying to pip inatall
a package which needs root permissions in airflow Dockerfile.
The package is python-lzo
.
Python 3.7, airflow 2.3.0.
The error I get is a known: "trying to run pip as root", and do acknowledge it is a known issue/fact that according to the Airflow documentations here.
I tried setting the environment variable as this solution stated and it still did not work.
The following example adds lxml python package from PyPI to the image. When adding packages via pip you need to use the airflow user rather than root. Attempts to install pip packages as root will fail with an appropriate error message.
They say you must run pip as the "airflow" user and not the "root".
However, the package I need is called "python-lzo" which needs to run gcc, and gcc only runs as root.
Is there an alternative way to install python-lzo on Airflow, if it needs gcc with root permissions?
Some people suggested I compile the python-lzo library and run gcc in my local computer, then somehow upload it to the Dockerfile, however I am pretty lost there because I don't understand how it's possible, when compiling it locally it means it's dependant on my OS, and I want the DAG to run on Linux (I have Windows).
The dockerfile:
From artifactory.whatever
Copy requirements.txt
Copy pip.ini ~/.pip/pip.conf
Copy mylibrary.whl
Env PIP_CONFIG_FILE ~/.pip/pip.conf
USER root
Run pip install mylibrary
The mylibrary
is a .whl I compiled using poetry
and in the requirements there is the library python-lzo
.