Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 866
Åsmund Sælen Avatar asked Dec 15 '19 11:12

Åsmund Sælen


People also ask

How to install black formatter for Python?

Black can be installed by running pip install black . It requires Python 3.7+ to run. If you want to format Jupyter Notebooks, install with pip install 'black[jupyter]' .

Is black the best Python formatter?

Black is the uncompromising Python code formatter. By using it, you agree to cede control over minutiae of hand-formatting. In return, Black gives you speed, determinism, and freedom from pycodestyle nagging about formatting. You will save time and mental energy for more important matters.


1 Answers

Try reinstalling and upgrading both typed-ast and black:

pip install --force-reinstall --upgrade typed-ast black
like image 112
RafalS Avatar answered Nov 28 '22 05:11

RafalS