How to Install black in Python
The uncompromising code formatter.
pip install black
What is black?
The uncompromising code 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 nagging about formatting. You will save time and mental energy for more important matters.
Blackened code looks the same regardless of the project you're reading. Formatting becomes transparent after a while and you can focus on the content instead.
Black makes code review faster by producing the smallest diffs possible.
Quick Start
Minimal example to get started with black:
import black
print(black.__version__)
Installation
pip (standard)
pip install black
Virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install black
pip3
pip3 install black
conda
conda install -c conda-forge black
Poetry
poetry add black
Dependencies
Installing black will also install these packages:
Verify the Installation
After installing, confirm the package is available:
python -c "import black; print(black.__version__)"
If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.
Installation Errors
Common errors when installing black with pip.
ModuleNotFoundError: No module named 'black'
Cause: The package is not installed in the current Python environment.
Fix: Run pip install black. If using a virtual environment, ensure it is activated first.
ModuleNotFoundError: No module named 'black' (installed but still failing)
Cause: pip installed the package into a different Python than the one running your script.
Fix: Use python -m pip install black to install into the interpreter you are running.
ImportError: cannot import name 'X' from 'black'
Cause: The function or class does not exist in the installed version.
Fix: Check the version with pip show black and upgrade with pip install --upgrade black.
pip: command not found
Cause: pip is not in PATH or Python was not added to PATH during installation.
Fix: Try python -m pip install black. On macOS/Linux try pip3.
PermissionError: [Errno 13] Permission denied
Cause: No write access to the system Python package directory.
Fix: Use a virtual environment, or add --user: pip install --user black
SSL: CERTIFICATE_VERIFY_FAILED
Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.
Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org black
Recent Releases
| Version | Released |
|---|---|
26.3.1 latest |
2026-03-12 |
26.3.0 |
2026-03-06 |
26.1.0 |
2026-01-18 |
25.12.0 |
2025-12-08 |
26.1a1 |
2025-12-08 |
Manage black
Upgrade to latest version
pip install --upgrade black
Install a specific version
pip install black==26.3.1
Uninstall
pip uninstall black
Check what is installed
pip show black