{"record":{"id":"d1068abdae694a2d","repo":"pypa/pip","slug":"script-script-r-not-found-in-metadata-at-self-e","errorCode":null,"errorMessage":"Script {script!r} not found in metadata at {self.egg_info!r}","messagePattern":"Script (.+?) not found in metadata at (.+?)","errorType":"exception","errorClass":"ResolutionError","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/pkg_resources/__init__.py","lineNumber":1701,"sourceCode":"\n    def resource_isdir(self, resource_name: str):\n        return self._isdir(self._fn(self.module_path, resource_name))\n\n    def metadata_isdir(self, name: str) -> bool:\n        return bool(self.egg_info and self._isdir(self._fn(self.egg_info, name)))\n\n    def resource_listdir(self, resource_name: str):\n        return self._listdir(self._fn(self.module_path, resource_name))\n\n    def metadata_listdir(self, name: str) -> list[str]:\n        if self.egg_info:\n            return self._listdir(self._fn(self.egg_info, name))\n        return []\n\n    def run_script(self, script_name: str, namespace: dict[str, Any]):\n        script = 'scripts/' + script_name\n        if not self.has_metadata(script):\n            raise ResolutionError(\n                \"Script {script!r} not found in metadata at {self.egg_info!r}\".format(\n                    **locals()\n                ),\n            )\n\n        script_text = self.get_metadata(script).replace('\\r\\n', '\\n')\n        script_text = script_text.replace('\\r', '\\n')\n        script_filename = self._fn(self.egg_info, script)\n        namespace['__file__'] = script_filename\n        if os.path.exists(script_filename):\n            source = _read_utf8_with_fallback(script_filename)\n            code = compile(source, script_filename, 'exec')\n            exec(code, namespace, namespace)\n        else:\n            from linecache import cache\n\n            cache[script_filename] = (\n                len(script_text),","sourceCodeStart":1683,"sourceCodeEnd":1719,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_vendor/pkg_resources/__init__.py#L1683-L1719","documentation":"Raised as ResolutionError by NullProvider.run_script() when the requested script name is not present in the distribution's EGG-INFO/scripts metadata. The message includes the script name and the egg_info path where it was expected. This means the package metadata does not declare that script.","triggerScenarios":"Calling dist.run_script('my_script', namespace) when 'scripts/my_script' is not listed in the package's EGG-INFO metadata (e.g. has_metadata('scripts/my_script') is False).","commonSituations":"A typo in the script name; the script was removed in a newer version of the package; the package was installed from a wheel without script metadata; calling run_script on a distribution that doesn't bundle that entry.","solutions":["Verify the script name against the package's EGG-INFO/scripts listing (dist.get_metadata_lines('scripts') or check entry points).","Correct the script name spelling/casing.","Use entry points (iter_entry_points) instead of run_script for modern package-script invocation."],"exampleFix":"// before\ndist.run_script('runServer', ns)  # name doesn't exist\n// after\nscripts = dist.get_metadata_lines('scripts')\n# pick the correct name from `scripts`\ndist.run_script(actual_name, ns)","handlingStrategy":"validation","validationCode":"script_path = 'scripts/' + script_name\nif not dist.has_metadata(script_path):\n    raise KeyError(f'{script_name} not in {dist} scripts')\ndist.run_script(script_name, ns)","typeGuard":"def script_exists(dist, name: str) -> bool:\n    return dist.has_metadata('scripts/' + name)","tryCatchPattern":"try:\n    dist.run_script(name, ns)\nexcept ResolutionError as e:\n    print(e)","preventionTips":["Check has_metadata('scripts/<name>') before calling run_script.","Prefer entry points over run_script for modern packaging."],"tags":["pkg-resources","scripts","metadata","resolution"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}