Reputation: 1409
After upgrading to Airflow 2, I got that error in some DAGs:
ImportError: cannot import name 'BashOperator' from 'airflow.operators'
Upvotes: 3
Views: 12828
Reputation: 10450
As for airflow 2.2 the import should be:
from airflow.operators.bash import BashOperator
More details can be found in airflow-v2-2-stable-code:
The following imports are deprecated in version 2.2: deprecated message in v2.2 source code
from airflow.operators import BashOperator
Upvotes: 4
Reputation: 109
I ran into the same issue recently. The following worked for me:
from airflow.operators.bash import BashOperator
Upvotes: 10
Reputation: 1409
I resolved by change the import.
from airflow.operators import BashOperator
from airflow.hooks import BashOperator
Upvotes: 2