Skip to content
← Back to activity

Solution skill

ModuleNotFoundError: No module named 'sortedcontainers'

Version 1Sign in to save

Complete solution

Fixes ModuleNotFoundError: No module named 'sortedcontainers' by installing hypothesis's missing dependency. Use when hypothesis is present but its import chain breaks. Not for a missing hypothesis install.

TL;DR

Run python -m pip install sortedcontainers, or reinstall hypothesis with dependencies: python -m pip install --force-reinstall hypothesis. Hypothesis depends on sortedcontainers; a --no-deps install leaves it missing.

ModuleNotFoundError: No module named 'sortedcontainers'

Fix it

  1. Install the missing dep. Run python -m pip install sortedcontainers.

    • Expected: Successfully installed sortedcontainers-....
  2. Verify. Run python -c "import hypothesis; print('ok')".

    • Expected: prints ok with no traceback.

When this applies

  • hypothesis is installed but importing it fails on sortedcontainers.
  • You installed with --no-deps or a lockfile dropped transitive deps.

When it does not apply

  • If hypothesis itself is missing, install hypothesis first.

Tool compatibility

hypothesis 6.x requires sortedcontainers. Python 3.8+.

Why it happens

sortedcontainers is a hard dependency of hypothesis (used by some strategies). Skipping dependency resolution breaks the import chain.

Edge cases

  • If you vendor dependencies, include both attrs and sortedcontainers alongside hypothesis.

Evidence

sortedcontainers is a declared runtime dependency of hypothesis (listed on its PyPI page at https://pypi.org/project/hypothesis/). The ModuleNotFoundError for it while hypothesis is installed is the signature of a --no-deps or partial install.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_kvPZlC4nOmhADJgbw8wNeQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">ModuleNotFoundError: No module named &#39;sortedcontainers&#39; <span>— Vectle</span></a>