A Python package offering additional routines for working with iterables, extending beyond the standard itertools module. Current version: 10.8.0. Maintained with regular updates to enhance functionality and performance.
Install & Compatibility
Where this runs
tested against v11.1.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
muslpy 3.10–3.925 runs
installs and imports cleanly · install 0.0s · import 0.040s · 18.3MB
glibcpy 3.10–3.925 runs
installs and imports cleanly · install 1.6s · import 0.036s · 19MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
chunked
✓ from more_itertools import chunked
Ensure correct import path to access the 'chunked' function.
windowed
✓ from more_itertools import windowed
Ensure correct import path to access the 'windowed' function.
Demonstrates the 'chunked' function to divide an iterable into chunks of specified size.
from more_itertools import chunked
iterable = [0, 1, 2, 3, 4, 5, 6, 7, 8]
result = list(chunked(iterable, 3))
print(result)
# Output:
# [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'more_itertools'
The 'more-itertools' package is not installed in your Python environment.
fixInstall the package using pip: `pip install more-itertools`
AttributeError: module 'more_itertools' has no attribute '__version__'
The `more_itertools` module does not expose its version via a `__version__` attribute directly within the module itself, unlike some other packages.
fixTo get the installed version, use `pkg_resources` or `importlib.metadata` (Python 3.8+): `import pkg_resources; pkg_resources.get_distribution('more-itertools').version` or `import importlib.metadata; importlib.metadata.version('more-itertools')` ImportError: cannot import name 'pairwise' from 'itertools'
The `pairwise` function was added to the standard `itertools` module in Python 3.10. If you are using an older Python version (e.g., 3.9 or below), `pairwise` is only available in the `more-itertools` library.
fixEither upgrade your Python version to 3.10 or newer, or import `pairwise` from `more_itertools`: `from more_itertools import pairwise` (after ensuring `more-itertools` is installed).
ValueError: chunked(): incomplete batch
This error occurs when using `more_itertools.chunked()` (or `sliced()`) with `strict=True`, and the length of the input iterable is not perfectly divisible by the chunk size `n`.
fixEither ensure the input iterable's length is a multiple of `n`, or remove `strict=True` to allow the last chunk to be shorter, or handle incomplete batches by setting `incomplete='fill'` or `incomplete='ignore'` (for `grouper`).
Audit
Dependencies
itertoolsrequiredStandard library module providing foundational iterable functions.