'airflow.exceptions.AirflowException: PythonVirtualenvOperator requires virtualenv, please install it
I set up my airflow using pypi. An error occurred after start the airflow server by below command: airflow standalone
airflow_version == 2.2.0
python_version == 3.8.4
but i have installed virtualenv.
Exception as below:
Broken DAG: [/usr/local/python3/lib/python3.8/site-
packages/airflow/example_dags/example_python_operator.py] Traceback
(most recent call last):
File "/usr/local/python3/lib/python3.8/site-
packages/airflow/models/baseoperator.py", line 188, in apply_defaults
result = func(self,*args,**kwargs)
File "/usr/local/python3/lib/python3.8/site-
packages/airflow/operators/python.py", line 342, in __init__
raise AirflowException('PythonVirtualenvOperator requires virtualenv,
please install it.')
airflow.exceptions.AirflowException: PythonVirtualenvOperator requires
virtualenv, please install it
I have no idea to fix the bug, don't know what's wrong happen.
Solution 1:[1]
We had the same issue running this in Google Cloud Build when trying to upgrade Airflow.
On closer inpection, it looks like Airflow uses the which command to check if virtualenv exists. Because we were using pip install virtualenv --user to persist package installations between build steps, we needed to add export PATH="/builder/home/.local/bin:$$PATH" to our build script.
To see if this will work for you:
- after install run
which virtualenvto see if it finds the virtualenv command - if it doesn't, add the folder that
virtualenvwas installed in to your PATH and try starting the Airflow server again
Solution 2:[2]
You need to install virtualenv package on the machine.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dan de Sybel |
| Solution 2 |



