{"record":{"id":"724cbd262147282f","repo":"pypa/pip","slug":"self-dist-is-installed-but-self-req-is-require-724cbd","errorCode":null,"errorMessage":"{self.dist} is installed but {self.req} is required by {self.required_by}","messagePattern":"(.+?) is installed but (.+?) is required by (.+?)","errorType":"exception","errorClass":"VersionConflict","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/pkg_resources/__init__.py","lineNumber":934,"sourceCode":"                    if dist is None:\n                        env = Environment(self.entries)\n                    else:\n                        # Use an empty environment and workingset to avoid\n                        # any further conflicts with the conflicting\n                        # distribution\n                        env = Environment([])\n                        ws = WorkingSet([])\n                dist = best[req.key] = env.best_match(\n                    req, ws, installer, replace_conflicting=replace_conflicting\n                )\n                if dist is None:\n                    requirers = required_by.get(req, None)\n                    raise DistributionNotFound(req, requirers)\n            to_activate.append(dist)\n        if dist not in req:\n            # Oops, the \"best\" so far conflicts with a dependency\n            dependent_req = required_by[req]\n            raise VersionConflict(dist, req).with_context(dependent_req)\n        return dist\n\n    @overload\n    def find_plugins(\n        self,\n        plugin_env: Environment,\n        full_env: Environment | None,\n        installer: _InstallerTypeT[_DistributionT],\n        fallback: bool = True,\n    ) -> tuple[list[_DistributionT], dict[Distribution, Exception]]: ...\n    @overload\n    def find_plugins(\n        self,\n        plugin_env: Environment,\n        full_env: Environment | None = None,\n        *,\n        installer: _InstallerTypeT[_DistributionT],\n        fallback: bool = True,","sourceCodeStart":916,"sourceCodeEnd":952,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_vendor/pkg_resources/__init__.py#L916-L952","documentation":"Raised as ContextualVersionConflict during WorkingSet.resolve() when the best-matching distribution found for a transitive dependency conflicts with that dependency's own requirement, and there is at least one known requirer. It is produced by calling VersionConflict(dist, req).with_context(dependent_req), which appends the set of requirers and switches the message template to include 'by {self.required_by}'. This surfaces multi-level dependency conflicts with attribution.","triggerScenarios":"During resolve(), package A requires 'lib>=2.0' and package B requires 'lib<2.0'; the resolver picks a lib version and one side conflicts, raising ContextualVersionConflict naming the installed dist, the unsatisfied req, and the dependent (requirer).","commonSituations":"Conflicting transitive version constraints between two installed packages; a plugin requiring a newer core library than the application pins; incompatible dependency pins across a monorepo.","solutions":["Read the 'required_by' field to identify which packages impose the conflicting constraints, then align them.","Upgrade or downgrade the contested dependency to a version satisfying all requirers, or relax one package's pin.","Use pip's resolver output (pip install with --dry-run) to find a compatible set, then pin that version."],"exampleFix":"// before\n# app pins lib==1.0, plugin needs lib>=2.0\npkg_resources.require(['app', 'plugin'])\n// after\n# upgrade lib to satisfy both, or drop the conflicting plugin\npip install 'lib>=2.0'\npkg_resources.require(['app', 'plugin'])","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    pkg_resources.require(deps)\nexcept ContextualVersionConflict as e:\n    print(e.report())\n    print('Required by:', e.required_by)","preventionTips":["Pin all transitive dependencies in a lock file to avoid conflicting ranges.","Use pip's resolver at install time to surface conflicts early."],"tags":["pkg-resources","dependency-conflict","version-conflict","contextual"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}