Airflow | cannot import name ‘resolve_types’ from ‘attr’

By | 29/01/2021

On setting up Airflow with Python 3.8 I was receiving an error when initialising the database.

from attr import fields, resolve_types
ImportError: cannot import name 'resolve_types' from 'attr' (/Users/username/.pyenv/versions/airflow_1_12/lib/python3.8/site-packages/attr/init.py)

There are certain dependencies which need to be installed with specific versions however when I tried to use

pip install apache-airflow==1.10.12 \
 --constraint "https://raw.githubusercontent.com/apache/airflow/constraints-1.10.12/constraints-3.7.txt"

I couldn’t get the install to complete. I ran the standard apache-airflow installation for Airflow 1.10.12 – however then got the ‘resolve_types’ error.

The fix for was to look at the version of attrs & cattrs installed. attrs was at version 19.3.0, wich was correct however I had to downgrade cattrs from 1.1.2 down to 1.0.0 – so it aligned with the version in the constraints file

Hope that helped