RajasGujarathi opened a new issue, #39953:
URL: https://github.com/apache/airflow/issues/39953
### 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_
```Dockerfile
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 https://github.com/apache/airflow/discussions/39905
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]