Registry / testing / isort
library9.0.0pypypi✓ verified 24d ago

isort is a Python utility and library designed to sort imports alphabetically, automatically separating them into sections by type. It provides a command-line utility, a Python library, and plugins for various editors to streamline import organization. Currently at version 8.0.1, isort maintains an active development pace with frequent major and minor releases, ensuring ongoing feature enhancements and bug fixes.

pip install isort
INSTALL
IMPORT
SIG · ISORT
I
isort
testingpythonv9.0.0
Install
1.8s avg
Import
201ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v9.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.214s · 22.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.188s · 24MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

isort
import isort
The `isort` module is imported directly for programmatic access to functions like `isort.code()` or `isort.file()`.

Demonstrates programmatic use of `isort` to sort a string of Python code and check if it's correctly sorted. The `isort.code()` function takes a string of code and returns the sorted version, while `isort.check_code()` verifies compliance.

import isort unsorted_code = '''import os import sys from third_party import lib from . import local_module''' sorted_code = isort.code(unsorted_code) print(sorted_code) # Example of checking if code is sorted correctly is_sorted = isort.check_code(sorted_code) print(f"Is the code sorted correctly? {is_sorted}")
isort --version
Debug
Known issues
breakingMajor versions of `isort` regularly drop support for older Python versions. Version 7.0.0 dropped support for Python 3.9, and version 6.0.0 dropped Python 3.8. Current versions (8.x) require Python >= 3.10.0.
fix
Ensure your project's Python interpreter meets the minimum requirement for your `isort` version or pin `isort` to an older version compatible with your environment.
affects: 6.0.0, 7.0.0, 8.x
breakingisort v8.0.0 removed the `setuptools` plugin and deprecated old finders flags and legacy finder logic. Version 6.1.0 also dropped the use of the non-standard `pkg_resources` API. Integrations relying on these components will break.
fix
Review your `isort` configuration and any custom scripts for usage of `setuptools` plugin or legacy finder flags. Update integrations to use `isort`'s official programmatic API or standard configuration methods. Refactor any code depending on `pkg_resources` for dependency discovery.
affects: 6.1.0, 8.0.0+
gotcha`isort` can conflict with other code formatters, notably `Black`, if not configured correctly. Both tools format imports but with different default styles.
fix
Always configure `isort` with the `black` profile when using it alongside `Black`. This can be done via `isort --profile black` on the command line, or by adding `profile = "black"` under `[tool.isort]` in your `pyproject.toml` or `[isort]` in `.isort.cfg`.
affects: All versions when used with `Black`
gotcha`isort` supports multiple configuration file formats (`pyproject.toml`, `.isort.cfg`, `setup.cfg`, `tox.ini`, `.editorconfig`), which can lead to confusion regarding precedence and correct syntax. For `pyproject.toml`, settings must be under `[tool.isort]`.
fix
Consolidate your configuration into a single, preferred file format like `pyproject.toml` (using `[tool.isort]`) or `.isort.cfg` (using `[settings]` or `[isort]`). Use `isort --verbose` to confirm which configuration file is being used for a given path.
affects: All versions
gotchaThe `--atomic` flag, which prevents `isort` from applying changes that introduce syntax errors, is disabled by default. Using it can prevent `isort` from running against code written using a different Python version than the one `isort` is run with.
fix
Be mindful when using `--atomic` in CI/CD environments, especially in projects with diverse Python version targets. It's often safer to rely on your test suite or linter to catch syntax errors after `isort` runs without `--atomic`.
affects: All versions
gotchaPrior to version 8.0.0, `isort` had an edge case where it could incorrectly handle `__future__` imports. While fixed in 8.0.0, older versions might exhibit subtle issues.
fix
Upgrade to `isort` 8.0.0 or newer if your project relies heavily on `__future__` imports and you encounter unexpected formatting behavior. Otherwise, carefully review `isort`'s output on such files.
affects: < 8.0.0
Errors
Common errors & fixes
Imports are incorrectly sorted.
The import statements in the file do not adhere to isort's configured sorting and formatting rules.
fix
Run `isort .` (or `isort <path/to/file.py>`) from your terminal to automatically sort and fix the imports. If using pre-commit, ensure `isort` is configured correctly.
isort conflicts with black
isort's default sorting behavior is incompatible with black's formatting style, causing them to continuously undo each other's changes, especially when used together in pre-commit hooks.
fix
Configure isort to use the 'black' profile. Add `profile = black` under the `[tool.isort]` section in your `pyproject.toml` or in a `.isort.cfg` file. Alternatively, run `isort . --profile black`.
ModuleNotFoundError: No module named 'isort'
The 'isort' package is not installed in the Python environment currently being used by your terminal, editor, or automation tool (like a pre-commit hook).
fix
Install isort using pip: `pip install isort`. Ensure you install it in the correct Python environment (e.g., your project's virtual environment).
Found <module> import while parsing, but <section> was not included in the `sections` setting of your config.
isort encountered an import statement for a module that it couldn't categorize into one of the defined sections (e.g., STDLIB, THIRDPARTY, FIRSTPARTY, LOCALFOLDER) in your configuration.
fix
Define the missing section in your isort configuration (e.g., in `pyproject.toml` or `.isort.cfg`) by adding it to the `sections` setting, and/or explicitly tell isort which modules belong to which section using `known_first_party`, `known_third_party`, `known_local_folder`, etc.
isort was told to use the settings_path: <path> as the base directory or file that represents the starting point of config file discovery, but it does not exist.
isort cannot find the configuration file or directory specified by the `settings_path` argument or implied by its discovery mechanism.
fix
Ensure the path provided for `settings_path` (or the location where you expect isort to find its config) is correct and the file/directory actually exists. Use `isort --show-config` to debug how isort is discovering its configuration.
Upgrade
Version history
9.0.0latest on PyPI · released Aug 26, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
isort — pip install isort · libregistry