pypa/pip · error · InstallationError
Editable requirements are not allowed as constraints
Error message
Editable requirements are not allowed as constraints
What it means
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.
Source
Thrown at src/pip/_internal/req/constructors.py:265
return RequirementParts(req, link, None, extras_override)
# ---- The actual constructors follow ----
def install_req_from_editable(
editable_req: str,
comes_from: InstallRequirement | str | None = None,
*,
isolated: bool = False,
hash_options: dict[str, list[str]] | None = None,
constraint: bool = False,
user_supplied: bool = False,
config_settings: dict[str, str | list[str]] | None = None,
) -> InstallRequirement:
if constraint:
raise InstallationError("Editable requirements are not allowed as constraints")
parts = parse_req_from_editable(editable_req)
return InstallRequirement(
parts.requirement,
comes_from=comes_from,
user_supplied=user_supplied,
editable=True,
link=parts.link,
constraint=constraint,
isolated=isolated,
hash_options=hash_options,
config_settings=config_settings,
extras=parts.extras,
)
def _looks_like_path(name: str) -> bool:
"""Checks whether the string "looks like" a path on the filesystem.View on GitHub (pinned to d7d0d0a394)
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`.
Example fix
# before (constraints.txt) -e ./local_project # after (move to requirements.txt) -e ./local_project # constraints.txt should only contain version pins like: # somepackage==1.2.3
Defensive patterns
Strategy: validation
Validate before calling
def assert_not_editable_constraint(spec: str, is_constraint: bool) -> None:
if is_constraint and spec.startswith("-e "):
raise ValueError("Editable requirements cannot be used as constraints") Type guard
null
Try / catch
null
Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- {editable_req} is not a valid editable requirement. It shoul
- Could not detect requirement name for '{editable_req}', plea
- Invalid requirement: {name!r}: {exc}
- Directory {name!r} is not installable. Neither 'setup.py' no
- Invalid requirement: {req_as_string!r}: {exc}
AI-assisted analysis of pypa/pip@d7d0d0a394 (2026-08-04).
Data as JSON: /data/errors/14335efc1ae48df2.json.
Report an issue: GitHub.