{"id":"e27c360171f0c729","repo":"python-poetry/poetry","slug":"package-package-not-found","errorCode":null,"errorMessage":"Package {package} not found","messagePattern":"Package (.+?) not found","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/poetry/console/commands/show.py","lineNumber":188,"sourceCode":"        if self.poetry.package.name == POETRY_SYSTEM_PROJECT_NAME:\n            return \"poetry self lock\"\n\n        return \"poetry lock\"\n\n    def _display_single_package_information(\n        self, package: str, locked_repository: Repository\n    ) -> int:\n        locked_packages = locked_repository.packages\n        canonicalized_package = canonicalize_name(package)\n        pkg = None\n\n        for locked in locked_packages:\n            if locked.name == canonicalized_package:\n                pkg = locked\n                break\n\n        if not pkg:\n            raise ValueError(f\"Package {package} not found\")\n\n        required_by = reverse_deps(pkg, locked_repository)\n\n        if self.option(\"tree\"):\n            if self.option(\"why\"):\n                # The default case if there's no reverse dependencies is to query\n                # the subtree for pkg but if any rev-deps exist we'll query for each\n                # of them in turn\n                packages = [pkg]\n                if required_by:\n                    packages = [\n                        p for p in locked_packages for r in required_by if p.name == r\n                    ]\n                else:\n                    # if no rev-deps exist we'll make this clear as it can otherwise\n                    # look very odd for packages that also have no or few direct\n                    # dependencies\n                    self.io.write_line(f\"Package {package} is a direct dependency.\")","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/console/commands/show.py#L170-L206","documentation":"ValueError from `_display_single_package_information` (show.py:187-188) when the requested package name (canonicalized) is not present among the locked packages. `poetry show <pkg>` only displays packages recorded in `poetry.lock`.","triggerScenarios":"Running `poetry show foes` for a package not in the lock file; querying before `poetry lock` has been run; lock file out of date.","commonSituations":"Typos; package is a transitive dep not surfaced in the lock subset; lock file stale after pyproject edits.","solutions":["Refresh the lock file: `poetry lock --no-update` then retry.","Verify the name with `poetry show` (lists all locked packages).","Add the package with `poetry add` if it should be a direct dependency."],"exampleFix":"# before\npoetry show requets\n# after\npoetry show requests","handlingStrategy":"validation","validationCode":"from poetry.factory import Factory\nfrom packaging.utils import canonicalize_name\npoetry = Factory().create_poetry()\nlocked = {p.name for p in poetry.locker.locked_repository().packages}\nif canonicalize_name(\"requests\") not in locked:\n    raise SystemExit(\"package not in lock file\")","typeGuard":"def in_lockfile(poetry, name: str) -> bool:\n    from packaging.utils import canonicalize_name\n    target = canonicalize_name(name)\n    return any(p.name == target for p in poetry.locker.locked_repository().packages)","tryCatchPattern":null,"preventionTips":["Run `poetry lock --no-update` after editing dependencies.","Canonicalize names before querying.","Script `poetry show` lookups against the lock file."],"tags":["show","lockfile","validation"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}