The Airflow Pylance reportMissingImports can be fixed by installing the apache-airflow python library within your virtual environment and then enter the path where Visual Studio Code (or any other IDE) can find it.
If you are using poetry as python package manager (more on poetry here) and Visual Studio Code (VSC):
-
Run
poetry add apache-airflow -
Find the path where the poetry virtual environment is located on your system:
poetry env info --path -
On VSC, open the Command Palette, then
>Python: Select Interpreterand enter the path returned in the above command.
After this is done, you will not have those error anymore:
Import "airflow" could not be resolved Pylance reportMissingImports
Note: this method remains valid for all report Missing Imports errors you might encounter.
