{"id":"5b5630fa8886da4b","repo":"python-poetry/poetry","slug":"incompatible-constraints-in-requirements-of-packa","errorCode":null,"errorMessage":"Incompatible constraints in requirements of {package}:\n{constraints}","messagePattern":"Incompatible constraints in requirements of (.+?):\n(.+?)","errorType":"exception","errorClass":"IncompatibleConstraintsError","httpStatus":null,"severity":"error","filePath":"src/poetry/puzzle/provider.py","lineNumber":1077,"sourceCode":"            used_marker_intersection: BaseMarker = AnyMarker()\n            for m in markers:\n                used_marker_intersection = used_marker_intersection.intersect(m)\n            if not self._is_relevant_marker(used_marker_intersection, active_extras):\n                continue\n\n            # intersection of constraints\n            constraint: VersionConstraint = VersionRange()\n            specific_source_dependency = None\n            used_dependencies = list(itertools.compress(dependencies, uses))\n            for dep in used_dependencies:\n                if dep.is_direct_origin() or dep.source_name:\n                    # if direct origin or specific source:\n                    # conflict if specific source already set and not the same\n                    if specific_source_dependency and (\n                        not dep.is_same_source_as(specific_source_dependency)\n                        or dep.source_name != specific_source_dependency.source_name\n                    ):\n                        raise IncompatibleConstraintsError(\n                            package, dep, specific_source_dependency, with_sources=True\n                        )\n                    specific_source_dependency = dep\n                constraint = constraint.intersect(dep.constraint)\n            if constraint.is_empty():\n                # conflict in overlapping area\n                raise IncompatibleConstraintsError(package, *used_dependencies)\n\n            if not any(uses):\n                if not cover_leftover_marker_space:\n                    # Caller is responsible for the leftover marker space.\n                    continue\n\n                # This is an edge case where the dependency is not required\n                # for the resulting marker. However, we have to consider it anyway\n                #  in order to not miss other dependencies later, for instance:\n                #   • foo (1.0) ; python == 3.7\n                #   • foo (2.0) ; python == 3.8","sourceCodeStart":1059,"sourceCodeEnd":1095,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/puzzle/provider.py#L1059-L1095","documentation":"Raised as IncompatibleConstraintsError when the same dependency is required from two different sources (source_name or direct-origin) that cannot be unified, or when overlapping version constraints intersect to an empty set. The error message lists the conflicting PEP 508 constraints so the user can see exactly what clashes.","triggerScenarios":"During dependency resolution (poetry lock/install/update), the provider aggregates multiple requirements for one package. If two requirements pin the package to different sources (e.g. one from PyPI, one from a private repo) or to disjoint version ranges, IncompatibleConstraintsError is raised — either the with_sources variant (line 1077) or the version-intersection variant (line 1084).","commonSituations":"Declaring the same package twice with different sources (e.g. `requests = {version='*', source='pypi'}` and `requests = {version='*', source='private'}`); conflicting version pins across a monorepo; a transitive dep pinned incompatible with a direct dep; mixing a direct url/vcs dep with a registry dep for the same package.","solutions":["Read the listed constraints to identify the two conflicting requirements.","Pick one source for the package and make all declarations use it consistently.","Loosen or align version constraints so their intersection is non-empty.","If one declaration is transitive, use a constraint override or remove the conflicting direct pin.","Use `poetry lock -vvv` to see which packages introduce the conflicting requirements."],"exampleFix":"// before: same package from two sources\n[[tool.poetry.source]]\nname = \"private\"\nurl = \"https://private.pypi/simple/\"\n[tool.poetry.dependencies]\nrequests = {version = '*', source = 'pypi'}\nrequests = {version = '*', source = 'private'}  # conflict\n\n// after: choose one source\n[tool.poetry.dependencies]\nrequests = {version = '*', source = 'private'}","handlingStrategy":"validation","validationCode":"from poetry.core.constraints.version import parse_constraint, VersionRange\n\ndef constraints_compatible(constraints: list[str]) -> bool:\n    acc = VersionRange()\n    for c in constraints:\n        acc = acc.intersect(parse_constraint(c))\n    return not acc.is_empty()","typeGuard":null,"tryCatchPattern":"from poetry.puzzle.provider import IncompatibleConstraintsError\n\ntry:\n    poetry.lock()\nexcept IncompatibleConstraintsError as e:\n    # parse listed constraints, realign sources/versions, then retry\n    ...","preventionTips":["Declare each package from exactly one source across the project.","Keep version constraints permissive enough to intersect.","Run `poetry lock -vvv` after dependency changes to surface conflicts early.","Avoid mixing direct-origin (url/vcs) and registry declarations for the same package."],"tags":["dependency","puzzle","constraints","resolver","source"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}