upodroid opened a new issue, #49483:
URL: https://github.com/apache/airflow/issues/49483

   ### Apache Airflow version
   
   Other Airflow 2 version (please specify below)
   
   ### If "Other Airflow 2 version" selected, which one?
   
   2.10.2
   
   ### What happened?
   
   I'm unable to use virtualenvoperator with airflow 2.10.2, it fails with the 
following error `SyntaxError: cannot assign to expression here. Maybe you meant 
'==' instead of '='?`
   
   
   I can't upgrade to 2.10.5 as the latest version offered by Google Composer 
is 2.10.2. Is there anything I can do to mitigate this bug?
   
   I can't repro the bug in 2.10.5
   
   ### What you think should happen instead?
   
   _No response_
   
   ### How to reproduce
   
   Sample dag to reproduce the error:
   
   ```python
   from airflow.decorators import dag, task
   import datetime
   
   @dag(
       "debug-venv",
       description="Debug broken venv in Airflow in 2.10.2",
       schedule_interval="@daily",
       schedule=None,
       start_date=datetime.datetime(2025, 4, 9),
       render_template_as_native_obj=True,
       max_active_runs=1,
   )
   def debug_dag():
       @task.virtualenv(
           task_id="virtualenv_python", requirements=["colorama==0.4.0", 
"tqdm"], system_site_packages=False, use_dill=True,
       )
       def callable_virtualenv():
           """
           Example function that will be performed in a virtual environment.
   
           Importing at the module level ensures that it will not attempt to 
import the
           library before it is installed.
           """
           from time import sleep
   
           from colorama import Back, Fore, Style
   
           print(Fore.RED + "some red text")
           print(Back.GREEN + "and with a green background")
           print(Style.DIM + "and in dim text")
           print(Style.RESET_ALL)
           for _ in range(4):
               print(Style.DIM + "Please wait...", flush=True)
               sleep(1)
           print("Finished")
       
       _ = callable_virtualenv()
   
   # Create the DAG
   dag = debug_dag()
   ```
   
   ### Operating System
   
   docker image
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Docker-Compose
   
   ### Deployment details
   
   I can reproduce this bug in both 2.10.2 docker compose and the Google Cloud 
Composer deployment. 
   
   ### Anything else?
   
   ```
   [2025-04-20, 20:33:23 UTC] {process_utils.py:194} INFO - Successfully 
installed colorama-0.4.0 dill-0.4.0 tqdm-4.67.1
   [2025-04-20, 20:33:24 UTC] {process_utils.py:194} INFO - 
   [2025-04-20, 20:33:24 UTC] {process_utils.py:194} INFO - [notice] A new 
release of pip is available: 24.2 -> 25.0.1
   [2025-04-20, 20:33:24 UTC] {process_utils.py:194} INFO - [notice] To update, 
run: python -m pip install --upgrade pip
   [2025-04-20, 20:33:24 UTC] {process_utils.py:186} INFO - Executing cmd: 
/tmp/venvu12wvyer/bin/python /tmp/venv-call8utfx9kr/script.py 
/tmp/venv-call8utfx9kr/script.in /tmp/venv-call8utfx9kr/script.out 
/tmp/venv-call8utfx9kr/string_args.txt /tmp/venv-call8utfx9kr/termination.log
   [2025-04-20, 20:33:24 UTC] {process_utils.py:190} INFO - Output:
   [2025-04-20, 20:33:24 UTC] {process_utils.py:194} INFO -   File 
"/tmp/venv-call8utfx9kr/script.py", line 44
   [2025-04-20, 20:33:24 UTC] {process_utils.py:194} INFO -     
unusual_prefix_581af55118a2ed4c02f0e5d18fb83c7871133711_venv-debug  = 
types.ModuleType("unusual_prefix_581af55118a2ed4c02f0e5d18fb83c7871133711_venv-debug")
   [2025-04-20, 20:33:24 UTC] {process_utils.py:194} INFO -     
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   [2025-04-20, 20:33:24 UTC] {process_utils.py:194} INFO - SyntaxError: cannot 
assign to expression here. Maybe you meant '==' instead of '='?
   [2025-04-20, 20:33:24 UTC] {taskinstance.py:3310} ERROR - Task failed with 
exception
   Traceback (most recent call last):
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/taskinstance.py",
 line 767, in _execute_task
       result = _execute_callable(context=context, **execute_callable_kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/taskinstance.py",
 line 733, in _execute_callable
       return ExecutionCallableRunner(
              ^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/utils/operator_helpers.py",
 line 252, in run
       return self.func(*args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/baseoperator.py",
 line 406, in wrapper
       return func(self, *args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/decorators/base.py", 
line 266, in execute
       return_value = super().execute(context)
                      ^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/baseoperator.py",
 line 406, in wrapper
       return func(self, *args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/operators/python.py",
 line 505, in execute
       return super().execute(context=serializable_context)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/baseoperator.py",
 line 406, in wrapper
       return func(self, *args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/operators/python.py",
 line 238, in execute
       return_value = self.execute_callable()
                      ^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/operators/python.py",
 line 870, in execute_callable
       result = self._execute_python_callable_in_subprocess(python_path)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/operators/python.py",
 line 570, in _execute_python_callable_in_subprocess
       execute_in_subprocess(
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/utils/process_utils.py",
 line 175, in execute_in_subprocess
       execute_in_subprocess_with_kwargs(cmd, cwd=cwd, env=env)
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/utils/process_utils.py",
 line 198, in execute_in_subprocess_with_kwargs
       raise subprocess.CalledProcessError(exit_code, cmd)
   subprocess.CalledProcessError: Command '['/tmp/venvu12wvyer/bin/python', 
'/tmp/venv-call8utfx9kr/script.py', '/tmp/venv-call8utfx9kr/script.in', 
'/tmp/venv-call8utfx9kr/script.out', '/tmp/venv-call8utfx9kr/string_args.txt', 
'/tmp/venv-call8utfx9kr/termination.log']' returned non-zero exit status 1.
   [2025-04-20, 20:33:24 UTC] {taskinstance.py:1225} INFO - Marking task as 
FAILED. dag_id=debug-venv, task_id=virtualenv_python, 
run_id=manual__2025-04-20T20:33:21.599907+00:00, 
execution_date=20250420T203321, start_date=20250420T203322, 
end_date=20250420T203324
   [2025-04-20, 20:33:24 UTC] {taskinstance.py:340} ▶ Post task execution logs
   ```
   
   ### 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]

Reply via email to