Formatter black is not working on my VSCode…but why? Code Answer

I have started using Python and Django and I am very new in this field. And this is my first time to ask a question here…I do apologise in advance if there is a known solution to this issue…

When I installed and set VSCode formatter ‘black’ (after setting linter as flake8), the tutorial video tutor’s side shows up pop-up like ‘formatter autopep8 is not installed. install?’. & Mine did not show up that message.

So what I did was…

  1. manually input ‘pipenv install flack –dev –pre’ on terminal.
  2. manually input “python.formatting.provider”: “black”, to ‘settings.json’ on ‘.vscode’ folder.
  3. Setting(VSCode) -> flake8, Python > Linting: Flake8 Enabled (Also modified in: workspace), (ticked the box) Whether to lint Python files using flake8

The bottom code is from settings.json (on vscode folder).

  "python.linting.pylintEnabled": false,
  "python.linting.flake8Enabled": true,
  "python.linting.enabled": true,
  "python.formatting.provider": "black", # input manually
  "python.linting.flake8Args": ["--max-line-length=88"] # input manually

I found a ‘black formatter’ document. & it stated… python -m black {source_file_or_directory} & I get the following error message.

    Usage: [OPTIONS] [SRC]...
Try ' -h' for help.

Error: Invalid value for '[SRC]...': Path '{source_file_or_directory}' does not exist.

Yes, honestly, I am not sure which source_file_or_directory I should set…but above all now I am afraid whether I am on the right track or not.

Can I hear your advice? At least some direction to go, please. Thanks..


The best way to use black is through terminal in my opinion. All you need to do is install it on pip on terminal using: pip install black Then when it’s installed you go onto terminal and type: black

the full line would be: black filepath/ So for a file called located on desktop if on mac: black desktop/ If you want to do it on multiple files than do it individually to each file.

Related Posts

© No Copyrights, All Questions are retrived from public domain.
Tutorial Guruji