{"id":"9f3eaa4545709865","repo":"pypa/pip","slug":"missing-version-header-and-or-file-at-path","errorCode":null,"errorMessage":"Missing 'Version:' header and/or {} file at path: {}","messagePattern":"Missing 'Version:' header and/or (.+?) file at path: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/pkg_resources/__init__.py","lineNumber":3024,"sourceCode":"            *************************************************************************\n            \\n\\n!!\n            \"\"\"\n            warnings.warn(msg, DeprecationWarning)\n\n            return self._parsed_version\n\n    @property\n    def version(self):\n        try:\n            return self._version\n        except AttributeError as e:\n            version = self._get_version()\n            if version is None:\n                path = self._get_metadata_path_for_display(self.PKG_INFO)\n                msg = (\"Missing 'Version:' header and/or {} file at path: {}\").format(\n                    self.PKG_INFO, path\n                )\n                raise ValueError(msg, self) from e\n\n            return version\n\n    @property\n    def _dep_map(self):\n        \"\"\"\n        A map of extra to its list of (direct) requirements\n        for this distribution, including the null extra.\n        \"\"\"\n        try:\n            return self.__dep_map\n        except AttributeError:\n            self.__dep_map = self._filter_extras(self._build_dep_map())\n        return self.__dep_map\n\n    @staticmethod\n    def _filter_extras(dm: dict[str | None, list[Requirement]]):\n        \"\"\"","sourceCodeStart":3006,"sourceCodeEnd":3042,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_vendor/pkg_resources/__init__.py#L3006-L3042","documentation":"Raised from the Distribution.version property when _get_version() returns None, i.e. neither a cached _version nor a parseable 'Version:' header in the distribution's PKG-INFO/EGG-INFO metadata could be found. The message names the expected metadata file and its path so you can locate the broken distribution.","triggerScenarios":"Accessing dist.version for a Distribution whose metadata is missing, empty, or lacks a 'Version:' line — common with corrupt installs, incomplete wheels, or legacy eggs where PKG-INFO was stripped.","commonSituations":"A half-installed/corrupted package in site-packages, an sdist built without PEP 440 metadata, a manually unpacked egg missing PKG-INFO, or pkg_resources iterating a working set that contains a broken dist.","solutions":["Reinstall the named distribution (pip install --force-reinstall <pkg>) to regenerate valid PKG-INFO with a Version header.","Inspect the path printed in the message and confirm the PKG-INFO/METADATA file exists and contains a 'Version:' line; fix the build if missing.","If iterating a working set, skip or guard dist.version access with try/except ValueError for distributions known to lack metadata."],"exampleFix":"# before\ndistro = pkg_resources.get_distribution('brokenpkg')\nprint(distro.version)  # raises ValueError\n\n# after\ntry:\n    print(distro.version)\nexcept ValueError:\n    subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--force-reinstall', 'brokenpkg'])","handlingStrategy":"try-catch","validationCode":"def has_version(dist) -> bool:\n    try:\n        return dist._get_version() is not None\n    except Exception:\n        return False\nif not has_version(distro):\n    # reinstall before reading version\n    ...","typeGuard":"null","tryCatchPattern":"try:\n    v = dist.version\nexcept ValueError:\n    # metadata corrupt; reinstall or skip this dist\n    v = None","preventionTips":["Pin installers that produce PEP 517-compliant metadata.","Validate PKG-INFO/METADATA has a Version: line in CI for built artifacts."],"tags":["python","pkg-resources","metadata","packaging","version"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}