{"record":{"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/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/commands/index.py#L131-L167","documentation":"Raised by `pip index versions` when the package finder returns zero candidate versions for the query. get_available_package_versions at index.py:148 builds a set of candidate versions from finder.find_all_candidates(query); if the set is empty it raises DistributionNotFound. This can mean the package does not exist on any configured index, all candidates were yanked/excluded, or requires-python filtering removed everything.","triggerScenarios":"Querying a non-existent package name, a package only available on an index not configured, a package whose every release is yanked, or a package with no version compatible with the target Python (--python / requires-python).","commonSituations":"Typo in the package name, private index not added via --index-url/--extra-index-url, yanked releases, or targeting a Python version the package never supported.","solutions":["Verify the package name on the index (e.g. pypi.org) — check for typos.","Add the correct index: `--index-url` or `--extra-index-url` pointing at where the package lives.","Try `--pre` if only pre-release versions exist and prereleases are excluded by default.","    Adjust `--python`/`--ignore-requires-python` if requires-python filtering removed all candidates.","Confirm the package isn't fully yanked on the index."],"exampleFix":"// before\npip index versions nonexistntpkg\n// after\npip index versions numpy\n# or add a private index\npip index versions privatepkg --extra-index-url https://my.repo/simple","handlingStrategy":"validation","validationCode":"# Pre-check the package exists on the index before pip index versions\nimport subprocess, json\n\ndef package_has_versions(name, index_url=None):\n    cmd = [\"pip\", \"index\", \"versions\", name, \"--json\"]\n    if index_url:\n        cmd += [\"--extra-index-url\", index_url]\n    r = subprocess.run(cmd, capture_output=True, text=True)\n    if r.returncode != 0:\n        return False\n    data = json.loads(r.stdout)\n    return len(data.get(\"versions\", [])) > 0\n","typeGuard":null,"tryCatchPattern":"# Retry with alternate index on DistributionNotFound\nimport subprocess\ntry:\n    subprocess.run([\"pip\", \"index\", \"versions\", name], check=True)\nexcept subprocess.CalledProcessError:\n    subprocess.run([\"pip\", \"index\", \"versions\", name, \"--pre\", \"--ignore-requires-python\"], check=True)\n","preventionTips":["Verify the package name on the index (watch typos).","Configure --index-url/--extra-index-url for private packages.","Try --pre and --ignore-requires-python if versions seem missing."],"tags":["cli","pip-index","package-resolution","network","index"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}