{"id":"14335efc1ae48df2","repo":"pypa/pip","slug":"editable-requirements-are-not-allowed-as-constrain","errorCode":null,"errorMessage":"Editable requirements are not allowed as constraints","messagePattern":"Editable requirements are not allowed as constraints","errorType":"exception","errorClass":"InstallationError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/req/constructors.py","lineNumber":265,"sourceCode":"\n    return RequirementParts(req, link, None, extras_override)\n\n\n# ---- The actual constructors follow ----\n\n\ndef install_req_from_editable(\n    editable_req: str,\n    comes_from: InstallRequirement | str | None = None,\n    *,\n    isolated: bool = False,\n    hash_options: dict[str, list[str]] | None = None,\n    constraint: bool = False,\n    user_supplied: bool = False,\n    config_settings: dict[str, str | list[str]] | None = None,\n) -> InstallRequirement:\n    if constraint:\n        raise InstallationError(\"Editable requirements are not allowed as constraints\")\n\n    parts = parse_req_from_editable(editable_req)\n    return InstallRequirement(\n        parts.requirement,\n        comes_from=comes_from,\n        user_supplied=user_supplied,\n        editable=True,\n        link=parts.link,\n        constraint=constraint,\n        isolated=isolated,\n        hash_options=hash_options,\n        config_settings=config_settings,\n        extras=parts.extras,\n    )\n\n\ndef _looks_like_path(name: str) -> bool:\n    \"\"\"Checks whether the string \"looks like\" a path on the filesystem.","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/req/constructors.py#L247-L283","documentation":"Raised by install_req_from_editable() when an editable requirement is also flagged as a constraint (constraint=True). pip's constraint files (-c constraints.txt) may only pin versions of regular requirements; editable installs are fundamentally unversioned source checkouts, so combining -e with -c is nonsensical and rejected at constructors.py:265.","triggerScenarios":"Putting a `-e ./path` or `-e git+...` line inside a constraints file passed via `pip install -c constraints.txt`. Or programmatically calling install_req_from_editable(..., constraint=True).","commonSituations":"Attempting to pin a local checkout's version via a constraints file. Migrating a requirements file to constraints and forgetting to remove -e lines. Misunderstanding that constraints constrain versions, not source locations.","solutions":["Remove the `-e` prefix from any line inside a constraints file; constraints must be plain version-pinning specifiers.","If you need the editable install, move that line into the main requirements file (passed with -r), not the constraints file (-c).","If you meant to constrain a normal dependency, drop -e and specify a version, e.g. `package==1.2.3`."],"exampleFix":"# before (constraints.txt)\n-e ./local_project\n# after (move to requirements.txt)\n-e ./local_project\n# constraints.txt should only contain version pins like:\n# somepackage==1.2.3","handlingStrategy":"validation","validationCode":"def assert_not_editable_constraint(spec: str, is_constraint: bool) -> None:\n    if is_constraint and spec.startswith(\"-e \"):\n        raise ValueError(\"Editable requirements cannot be used as constraints\")","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Keep constraints files (-c) limited to plain version pins; never put -e lines in them.","Put editable installs in requirements files (-r) instead.","Document in your repo which file is constraints vs requirements."],"tags":["editable","constraints","requirements","packaging"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}