{"id":"d42b3b6b73ee5894","repo":"pypa/pip","slug":"no-matching-distribution-found-for-query","errorCode":null,"errorMessage":"No matching distribution found for {query}","messagePattern":"No matching distribution found for (.+?)","errorType":"exception","errorClass":"DistributionNotFound","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/commands/index.py","lineNumber":149,"sourceCode":"            finder = self._build_package_finder(\n                options=options,\n                session=session,\n                target_python=target_python,\n                ignore_requires_python=options.ignore_requires_python,\n            )\n\n            versions: Iterable[Version] = (\n                candidate.version for candidate in finder.find_all_candidates(query)\n            )\n\n            if self.should_exclude_prerelease(options, canonicalize_name(query)):\n                versions = (\n                    version for version in versions if not version.is_prerelease\n                )\n            versions = set(versions)\n\n            if not versions:\n                raise DistributionNotFound(\n                    f\"No matching distribution found for {query}\"\n                )\n\n            formatted_versions = [str(ver) for ver in sorted(versions, reverse=True)]\n            latest = formatted_versions[0]\n\n        dist = get_installed_distribution(query)\n\n        if options.json:\n            structured_output = {\n                \"name\": query,\n                \"versions\": formatted_versions,\n                \"latest\": latest,\n            }\n\n            if dist is not None:\n                structured_output[\"installed_version\"] = str(dist.version)\n","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/commands/index.py#L131-L167","documentation":"Raised by IndexCommand.get_available_package_versions when finder.find_all_candidates(query) returns no versions (after optional prerelease filtering). This is a DistributionNotFound (a DiagnosticPipError), meaning pip contacted the index(es) but found zero installable candidates for the given name. Note this is the 'pip index versions' path, distinct from install-time DistributionNotFound which carries richer diagnostics.","triggerScenarios":"Running 'pip index versions <name>' where <name> does not exist on any configured index, or where all candidates are pre-releases and pre-releases are excluded by selection prefs.","commonSituations":"Typo in package name; package available on a private index not configured; package yanked/removed; --pre not set and only pre-releases exist; network/proxy returning an empty simple-API page; Python version filter excluding all wheels.","solutions":["Verify the package name spelling against the index (e.g. on PyPI).","Ensure the correct --index-url / --extra-index-url is configured.","If only pre-releases exist, allow them: pip index versions --pre <name>.","Check --python-version / --platform / --abi filters are not excluding all wheels.","Confirm network/proxy reach the index: curl -I <index-url>/simple/<name>/."],"exampleFix":"// before\npip index versions nonexistntpkg\n// after\npip index versions numpy","handlingStrategy":"try-catch","validationCode":"# Pre-check the package exists on the index before 'pip index versions'\nimport urllib.request, json\nurl = index_url.rstrip(\"/\") + f\"/simple/{name}/\"\ntry:\n    with urllib.request.urlopen(url, timeout=10) as r:\n        if r.status != 200:\n            raise SystemExit(f\"package {name!r} not reachable on {index_url}\")\nexcept Exception as e:\n    raise SystemExit(f\"cannot reach {url}: {e}\")","typeGuard":null,"tryCatchPattern":"try:\n    run_pip([\"index\", \"versions\", name])\nexcept DistributionNotFound:\n    # fall back: retry with --pre, or surface a friendly message\n    log.warning(\"no versions for %s on %s\", name, index_url)","preventionTips":["Verify the package name on the index before scripting against it.","Allow pre-releases with --pre when a package only has them.","Confirm --index-url and network/proxy reach the simple API."],"tags":["pip","index","distribution-not-found","network","package-resolution"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}