VS Code Python Formatter | How to Check Installation and Configure Black, isort, autopep8, flake8 in VS Code
- Posted on October 2, 2025
- Technology
- By MmantraTech
- 11 Views
Hmm this setup sometimes confuse beginners a bit, i tried few times and it was ok after small fixes. follow steps below to make VS Code use Black, isort and flake8 properly.
Check installation and configure Black, isort, autopep8, flake8 in VS Code

This guide shows how to check installation and configure black isort autopep8 flake8 setup in VS Code so formatting and linting work on save. In my experience, the most common issue is VS Code using a different interpreter than where you installed packages.
1. Check installation (pip show & install) — black isort autopep8 flake8 setup
Open your terminal (inside the Python environment you use for the project) and run the following to verify packages:
pip show black isort autopep8 flake8
If any package is missing, install them with:
pip install black isort autopep8 flake8
2. Enable Python extension in VS Code
Make sure you installed these extensions:
- Python (by Microsoft)
- Black Formatter (by Microsoft)
- (optional) Pylance
These ensure VS Code can discover Python interpreters and formatters.
3. Configure settings.json
(VS Code)
Open Command Palette → Preferences: Open Settings (JSON) and add the following. The crucial bit is the `[python]
` default formatter line — that forces VS Code to call Black for Python files.
{
"editor.formatOnSave": true,
"python.formatting.provider": "black",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"python.linting.enabled": true,
"python.linting.flake8Enabled": true
}
Note: the important line — "[python]": { "editor.defaultFormatter": "ms-python.black-formatter" }
— makes sure VS Code actually uses Black.
4. Test Black manually (black isort autopep8 flake8 setup)
Run Black on a file to confirm it works:
# black isort autopep8 flake8 setup
black your_file.py
If Black reformats the file, it is installed correctly. If not, try:
pip install black --upgrade
5. Check VS Code Python interpreter
VS Code sometimes uses a different interpreter than where you installed packages. Open Command Palette → Python: Select Interpreter and choose the interpreter/environment where you ran pip install
. This step fixes the most common mismatch.
Quick checklist (on-save behavior)
After the setup:
- On save, Black should reformat (blank lines, spacing rules).
- isort should reorder imports (if
source.organizeImports
is enabled or via isort extension). - flake8 will underline linting issues in the editor.
This combination gives a solid developer experience for consistent formatting and linting.
Troubleshooting tips I learned (personal touch)
- If formatting doesn't run on save, check which formatter is active under the status bar (bottom-right).
- If imports aren't reordered, try installing the isort
extension or ensure Python's isort package is in the same environment.
- If flake8 warnings don't show, ensure python.linting.flake8Enabled
is true and the interpreter has flake8 installed.
In my experience, selecting the correct interpreter fixed most issues quickly.
Conclusion — black isort autopep8 flake8 setup
Follow the steps above to check installation and configure the black isort autopep8 flake8 setup in VS Code. This ensures consistent formatting and catches lint issues early. This trick helped me when I joined new projects — a consistent formatter and linter save time and reduce style bikeshedding.
Write a Response