Update 2023-09-15:
Now VSCode has a Microsoft oficial Black Formatter extension. It will probably solve your problems.
Original answer:
I use Black from inside VSCode and it rocks. It frees mental cycles that you would spend deciding how to format your code. It's best to use it from your favorite editor. Just run from the command line if you need to format a lot of files at once.
First, check if you have this in your VSCode settings.json (open it with Ctrl-P + settings):
"python.formatting.provider": "black",
"editor.formatOnSave": true,
Remember that there may be 2 setting.json files: one in your home dir, and one in your project (.vscode/settings.json). The one inside the project prevails.
That said, these kind of problems usually are about using a python interpreter where black isn't installed. I recommend the use of virtual environments, but first check your python interpreter on the status bar:

If you didn't explicitly select an interpreter, do it now clicking on the Python version in your status bar. You can also do it with Ctrl-P + "Python: Select Interpreter". The status bar should change after selecting it.
Now open a new terminal. Since you selected your interpreter, your virtual environment should be automatically activated by VSCode. Run python using your interpreter path and try to import black:
$ python
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import black
>>>
Failed import? Problem solved. Just install black using the interpreter from the venv: python -m pip install black. You also can install using Conda, but in my experience VSCode works better with pip.
Still not working? Click in the "OUTPUT" tab sibling of the TERMINAL and try to get more info at the "Log" output (if you use the newer Black plugun it may be called "Black Formatter"). Select it in the pull down menu:

Videos
Update 2023-09-15:
Now VSCode has a Microsoft oficial Black Formatter extension. It will probably solve your problems.
Original answer:
I use Black from inside VSCode and it rocks. It frees mental cycles that you would spend deciding how to format your code. It's best to use it from your favorite editor. Just run from the command line if you need to format a lot of files at once.
First, check if you have this in your VSCode settings.json (open it with Ctrl-P + settings):
"python.formatting.provider": "black",
"editor.formatOnSave": true,
Remember that there may be 2 setting.json files: one in your home dir, and one in your project (.vscode/settings.json). The one inside the project prevails.
That said, these kind of problems usually are about using a python interpreter where black isn't installed. I recommend the use of virtual environments, but first check your python interpreter on the status bar:

If you didn't explicitly select an interpreter, do it now clicking on the Python version in your status bar. You can also do it with Ctrl-P + "Python: Select Interpreter". The status bar should change after selecting it.
Now open a new terminal. Since you selected your interpreter, your virtual environment should be automatically activated by VSCode. Run python using your interpreter path and try to import black:
$ python
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import black
>>>
Failed import? Problem solved. Just install black using the interpreter from the venv: python -m pip install black. You also can install using Conda, but in my experience VSCode works better with pip.
Still not working? Click in the "OUTPUT" tab sibling of the TERMINAL and try to get more info at the "Log" output (if you use the newer Black plugun it may be called "Black Formatter"). Select it in the pull down menu:

2024/02/19 updated
The previous solution doesn't work anymore.
There're two issues:
- vscode has new official extension
- different black output from vscode extension and black in your python virtual environment
If you just want to use 'black' formatter and don't care issue #2. Just install vscode black extension

I revised my solution for issue #2
a. install black extension first
b. set up your virtual environment, install black init and set your project interpreter to it
c. go to user setting, set Black-formatter: Path to "black" in your virtual environment
"black-formatter.path": ["black"]
NOTE: Install 'black' in the python environment you need, remove global 'black'
===== Obselete solution for old vscode =====
Attach my finding for those who still can't solve the Black formatting issue in VS Code.
First, you have to install Black globally or locally (if you use virtual env like conda).
Then, make sure your VS settings as following, set python default formatter provider as 'black':

Finally, open settings.json of your VS Code, add the following segment for it.
"[python]": {
"editor.defaultFormatter": null,
"editor.insertSpaces": true,
"editor.tabSize": 4,
"editor.formatOnSave": true
}
The key point is:
"editor.defaultFormatter": null
If you still use "editor.defaultFormatter": "black" as many old posts suggest, the Black formatter will not work in newer VS Code.
There are only a few settings you need to setup black as a formatter on VS Code. It seems you got most of it right, but I am doubtful about using relative paths for blackPath (VS Code should have shown an error if the path is indeed incorrect).
I suggest switching to absolute paths.
Here are my settings:
// User Settings
"editor.defaultFormatter": null,
"editor.formatOnSave": false, // enable per language
"[python]": {
"editor.formatOnSave": true
},
"python.formatting.provider": "black",
"python.formatting.blackPath": "/usr/local/bin/black"
// Workspace Settings
"python.formatting.blackPath": "/absolute/path/to/venv/with/black",
"python.formatting.blackArgs": [
"-l 120"
],
First of all, I suggest getting rid of the editor.defaultFormatter setting (or just set it back to the default null). Instead of setting a default for everything, configure your formatter for each language and for each extension. Here, it's null and then I configure python-specific settings then I have separate ones for other languages (ex. JS and C++). You mentioned something about Prettier, and that could be interfering with VS Code using black.
Second, make sure you are modifying the correct settings. VS Code has 3 sets of settings: User, Workspace, and Folder. I normally have the formatOnSave enabled for Python on the User settings, and provider set to black (using system-wide installed black). On a specific workspace, I have a virtual environment and I override the blackPath to the black specifically installed on that virtual environment. You can also just put all the settings in the User settings or use the same system-wide-installed black. But the main point here is to use absolute paths for both (basically copying the output of which black from the console).
Note that, if you specified blackPath to point to a particular virtual environment, make sure to select that same virtual environment on your workspace.
Lastly, you can check for any issues from the Output tab > Python:

I was also having the issue. What solved the issue for me was after downloading the Black formatter extension and once the document was open I did a right-click with the mouse and then press "format document". Choose black. I was good to go and had no more issues after that.
I am learning python from YouTube. And the Teacher was writing program in VS code. He did two things that didn't happen in my VS code.
Indentation correction. He told that if you give indentation before any variable it will show red. But if you Save it VS code/Pylance will auto correct it.
Imported modules and Libraries will move to the top after saving.
In my case none of the things happened. I have turned every setting on and updated the json file and yet nothing happens. I have also applied settings to all profiles and yet nothing.