Rajendra
Rajendra

Reputation: 61

How to install python black tool in python2.7

I need to test black check in travis.yml file which is having python2.7 version how to install black in that?

language: python
python:
- '2.7'
install:
- pip install black

Upvotes: 6

Views: 9066

Answers (3)

RaviTezu
RaviTezu

Reputation: 3125

Black requires Python 3.6+ and you may want to look at pre-commit as it is capable of creating a python3 virtual environment just for black.

Upvotes: 3

Alexey Shrub
Alexey Shrub

Reputation: 1314

pip3 install --user black[python2]

With python2 option black will check py2 code correctly, but for running black you need py3

Upvotes: 1

seralouk
seralouk

Reputation: 33147

Did you try?

pip install black

Black can be installed by running pip install black. It requires Python 3.6.0+ to run but you can reformat Python 2 code with it, too.

Ref: https://black.readthedocs.io/en/stable/installation_and_usage.html

Based on this topic (https://github.com/psf/black/issues/439) Black requires python 3.6 to run.

Try pip3 install black if python3 and pip3 are installed.

Upvotes: 0

Related Questions