{"record":{"id":"39dd1d953f0ff866","repo":"pypa/pip","slug":"could-not-satisfy-constraints-for-install-req-na","errorCode":null,"errorMessage":"Could not satisfy constraints for '{install_req.name}': installation from path or url cannot be constrained to a version","messagePattern":"Could not satisfy constraints for '(.+?)': installation from path or url cannot be constrained to a version","errorType":"exception","errorClass":"InstallationError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/resolution/legacy/resolver.py","lineNumber":285,"sourceCode":"            )\n\n        # When no existing requirement exists, add the requirement as a\n        # dependency and it will be scanned again after.\n        if not existing_req:\n            requirement_set.add_named_requirement(install_req)\n            # We'd want to rescan this requirement later\n            return [install_req], install_req\n\n        # Assume there's no need to scan, and that we've already\n        # encountered this for scanning.\n        if install_req.constraint or not existing_req.constraint:\n            return [], existing_req\n\n        does_not_satisfy_constraint = install_req.link and not (\n            existing_req.link and install_req.link.path == existing_req.link.path\n        )\n        if does_not_satisfy_constraint:\n            raise InstallationError(\n                f\"Could not satisfy constraints for '{install_req.name}': \"\n                \"installation from path or url cannot be \"\n                \"constrained to a version\"\n            )\n        # If we're now installing a constraint, mark the existing\n        # object for real installation.\n        existing_req.constraint = False\n        # If we're now installing a user supplied requirement,\n        # mark the existing object as such.\n        if install_req.user_supplied:\n            existing_req.user_supplied = True\n        existing_req.extras = tuple(\n            sorted(set(existing_req.extras) | set(install_req.extras))\n        )\n        logger.debug(\n            \"Setting %s extras to: %s\",\n            existing_req,\n            existing_req.extras,","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/resolution/legacy/resolver.py#L267-L303","documentation":"In the legacy resolver (resolver.py:281-289), when an existing requirement is a constraint and the new install_req is a link (path/url) whose path differs from the constraint's link, pip raises InstallationError. A path/url install cannot be constrained to a specific version because the version is whatever that path contains.","triggerScenarios":"Using -c constraints.txt where a package is constrained by version, while simultaneously installing that package from a local path or URL with a different path.","commonSituations":"Mixing version constraints (-c) with editable/VCS/path installs of the same package; constraints referencing a different source than the install.","solutions":["Do not version-constrain path/url installs; let the path define the version.","Make the constraint point to the same path as the install requirement.","Move the version pin out of the constraints file for path-installed packages."],"exampleFix":"# before\n# constraints.txt: pkg==1.0\npip install -c constraints.txt ./local/pkg\n# after\npip install ./local/pkg   # no version constraint on a path install","handlingStrategy":"validation","validationCode":"# Warn if a constraints file pins a version for a path/url requirement.\nimport re, os\nreqs = [l.strip() for l in open(\"requirements.txt\") if l.strip() and not l.startswith(\"-\")]\ncons = [l.strip() for l in open(\"constraints.txt\") if l.strip()]\npath_req_names = {\n    re.match(r\"([A-Za-z0-9_.-]+)\", l).group(1).lower()\n    for l in reqs\n    if (\"/\" in l or os.sep in l or l.startswith((\"git+\", \"http\", \"./\", \"..\")))\n}\nfor c in cons:\n    nm = re.match(r\"([A-Za-z0-9_.-]+)\", c)\n    if nm and nm.group(1).lower() in path_req_names and \"==\" in c:\n        print(f\"Avoid version-constraining path install: {c}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep version constraints and path/url installs separate.","Don't put version specifiers on -e or local-path requirements.","Document which packages are path-installed so constraints authors know."],"tags":["constraints","path-install","resolver"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}