Problem with using Black code formatter; can't import _ast3

9.4k views Asked by At

I want to use "Black code formatter" for one of my python projects. I've successfully installed it with "pip install black", which gave an output in the cmd which showed that all requirements were already satisfied (including "typed-ast>1.4.0").

However, when I try to run the "black --help" after installation, I get the error: "ImportError: cannot import the name '_ast3' from 'typed_ast". Does anyone know what might be the issue here?

2

There are 2 answers

0
RafalS On BEST ANSWER

Try reinstalling and upgrading both typed-ast and black:

pip install --force-reinstall --upgrade typed-ast black
0
HeyMan On

For me upgrading the black version did help. Here my tox.ini entry:

failed:

deps = black==20.8b1

works:

deps = black==21.10b0