After upgrading to Airflow 2 (and also in Airflow 3), I started getting this error in some DAGs:
ImportError: cannot import name 'BashOperator' from 'airflow.operators'
In Airflow 1.x I used:
from airflow.operators import BashOperator
But this no longer works after upgrading. What is the correct way to import BashOperator in Airflow 2+ / 3?
I resolved by change the import.
from airflow.operators import BashOperator
from airflow.hooks import BashOperator