Closed as not planned
Description
Apache Airflow version
2.9.1
If "Other Airflow 2 version" selected, which one?
No response
What happened?
Using the docker image apache/airflow:slim-2.9.1-python3.12
I installed an alternate Python version 3.9.
When using the PythonVirtualenvOperator in a DAG
.
.
python_3_9 = PythonVirtualenvOperator(task_id='python_3_9',
requirements=["colorama==0.4.0"],
system_site_packages=False,
python_callable=func,
python_version='3.9',
dag=dag)
.
.
The DAG fails with an error
{process_utils.py:183} INFO - Executing cmd: /home/***/.local/bin/python -m virtualenv /tmp/venv_4wv1u08 --python=python3.9
{process_utils.py:187} INFO - Output:
{process_utils.py:191} INFO - PermissionError: [Errno 13] Permission denied: '/root/bin'
What you think should happen instead?
The command for the creation of virtualenv should have been successful
How to reproduce
Non-optimised Dockerfile created only for simulating the behaviour
FROM apache/airflow:slim-2.9.1-python3.12
ARG ALTERNATE_PYTHON_VERSIONS="3.9.0"
WORKDIR /tmp
USER root
RUN apt-get update \
&& apt-get install -y --fix-missing --no-install-recommends \
zlib1g-dev \
wget \
libsasl2-dev \
libldap2-dev \
libssl-dev \
gcc \
make
USER airflow
WORKDIR $AIRFLOW_USER_HOME_DIR
RUN pip install virtualenv \
&& for ADD_PYTHON_VERSION in $ALTERNATE_PYTHON_VERSIONS; do \
wget --quiet "https://www.python.org/ftp/python/${ADD_PYTHON_VERSION}/Python-${ADD_PYTHON_VERSION}.tgz" \
&& tar xzf "Python-${ADD_PYTHON_VERSION}.tgz" \
&& cd "Python-${ADD_PYTHON_VERSION}" && ./configure --prefix=$AIRFLOW_USER_HOME_DIR/.local --enable-optimizations && make altinstall \
&& cd .. && rm -rf "Python-${ADD_PYTHON_VERSION}*" ; \
done
- Build the docker image
- Run the image -
docker run -it <image_name:tag> bash
- Create the virtualenv -
python -m virtualenv /tmp/venviplvcl3b --python=python3.9
- Modify the PATH environment variable, remove
/root/bin
- Try re-creating the virtualenv
Operating System
MacOS
Versions of Apache Airflow Providers
Not applicable
Deployment
Other Docker-based deployment
Deployment details
Extending apache/airflow:slim-2.9.1-python3.12
and then running a webserver, scheduler & worker
Anything else?
The user airflow
has a path /root/bin
on its $PATH but does not have access to this directory, can this be the cause of the error?
Discussion #39905
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct