python-poetry/poetry · error · IncompatibleConstraintsError
Incompatible constraints in requirements of {package}: {cons
Error message
Incompatible constraints in requirements of {package}:
{constraints} What it means
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.
Source
Thrown at src/poetry/puzzle/provider.py:1077
used_marker_intersection: BaseMarker = AnyMarker()
for m in markers:
used_marker_intersection = used_marker_intersection.intersect(m)
if not self._is_relevant_marker(used_marker_intersection, active_extras):
continue
# intersection of constraints
constraint: VersionConstraint = VersionRange()
specific_source_dependency = None
used_dependencies = list(itertools.compress(dependencies, uses))
for dep in used_dependencies:
if dep.is_direct_origin() or dep.source_name:
# if direct origin or specific source:
# conflict if specific source already set and not the same
if specific_source_dependency and (
not dep.is_same_source_as(specific_source_dependency)
or dep.source_name != specific_source_dependency.source_name
):
raise IncompatibleConstraintsError(
package, dep, specific_source_dependency, with_sources=True
)
specific_source_dependency = dep
constraint = constraint.intersect(dep.constraint)
if constraint.is_empty():
# conflict in overlapping area
raise IncompatibleConstraintsError(package, *used_dependencies)
if not any(uses):
if not cover_leftover_marker_space:
# Caller is responsible for the leftover marker space.
continue
# This is an edge case where the dependency is not required
# for the resulting marker. However, we have to consider it anyway
# in order to not miss other dependencies later, for instance:
# • foo (1.0) ; python == 3.7
# • foo (2.0) ; python == 3.8View on GitHub (pinned to 92b74dcfe3)
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.
Example fix
// before: same package from two sources
[[tool.poetry.source]]
name = "private"
url = "https://private.pypi/simple/"
[tool.poetry.dependencies]
requests = {version = '*', source = 'pypi'}
requests = {version = '*', source = 'private'} # conflict
// after: choose one source
[tool.poetry.dependencies]
requests = {version = '*', source = 'private'} Defensive patterns
Strategy: validation
Validate before calling
from poetry.core.constraints.version import parse_constraint, VersionRange
def constraints_compatible(constraints: list[str]) -> bool:
acc = VersionRange()
for c in constraints:
acc = acc.intersect(parse_constraint(c))
return not acc.is_empty() Try / catch
from poetry.puzzle.provider import IncompatibleConstraintsError
try:
poetry.lock()
except IncompatibleConstraintsError as e:
# parse listed constraints, realign sources/versions, then retry
... Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- The dependency name for {dependency.name} does not match the
- {dependency}: unknown direct dependency type {dependency.sou
- Could not find a matching version of package {name}
- Unsupported VCS dependency {vcs}
- Invalid dependency specification: {requirement}
AI-assisted analysis of python-poetry/poetry@92b74dcfe3 (2026-08-04).
Data as JSON: /data/errors/5b5630fa8886da4b.json.
Report an issue: GitHub.