MatrixManAtYrService opened a new pull request #15788:
URL: https://github.com/apache/airflow/pull/15788


   While trying to use `@task.virtualenv` I got this error:
   
   ```
    File "/Users/matt/src/airflow/airflow/models/taskinstance.py", line 1340, 
in _execute_task
       result = task_copy.execute(context=context)
     File "/Users/matt/src/airflow/airflow/decorators/base.py", line 138, in 
execute
       return_value = super().execute(context)
     File "/Users/matt/src/airflow/airflow/operators/python.py", line 350, in 
execute
       return super().execute(context=serializable_context)
     File "/Users/matt/src/airflow/airflow/operators/python.py", line 152, in 
execute
       return_value = self.execute_callable()
     File "/Users/matt/src/airflow/airflow/operators/python.py", line 362, in 
execute_callable
       prepare_virtualenv(
     File "/Users/matt/src/airflow/airflow/utils/python_virtualenv.py", line 
95, in prepare_virtualenv
       execute_in_subprocess(virtualenv_cmd)
     File "/Users/matt/src/airflow/airflow/utils/process_utils.py", line 136, 
in execute_in_subprocess
       with subprocess.Popen(
     File 
"/usr/local/Cellar/[email protected]/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py",
 line 951, in __init__
       self._execute_child(args, executable, preexec_fn, close_fds,
     File 
"/usr/local/Cellar/[email protected]/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py",
 line 1821, in _execute_child
       raise child_exception_type(errno_num, err_msg, err_filename)
   FileNotFoundError: [Errno 2] No such file or directory: 'virtualenv'
   ```
   
   It was helpful enough that I was able to guess that `pip install virtualenv` 
would fix things for me, but:
    - The error could have come up earlier
    - `FileNotFoundError` made me doubt that it was a packaging issue
   
   This PR checks if virtualenv is importable at init time and throws a more 
helpful exception.
   
   I'm interested to know if there's a better way to handle things like this, 
but this is at least better than how it was.


-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to