{"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/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/resolution/legacy/resolver.py#L267-L303","documentation":"Raised by the legacy resolver when a package is both requested for installation from a path/URL and constrained by a -c constraints file, but the constraint's link path differs from the install link path. The legacy resolver cannot pin a path/URL source to a version, so it refuses rather than guess. This path is only hit when the new resolver is disabled (--use-deprecated=legacy-resolver) or unavailable.","triggerScenarios":"In _resolve_one: install_req has a link, existing_req is a constraint, and (existing_req.link is None OR install_req.link.path != existing_req.link.path). Concretely: requirements file has `./myfork` (or a git+ URL) while constraints file pins `mypkg==1.2` or points to a different path, run under the legacy resolver.","commonSituations":"Mixing editable/path/VCS installs with version constraints in a constraints file; migrating a constraints file that pins versions for packages you now install from a local checkout; CI that pins `-c constraints.txt` while also installing a fork from a URL.","solutions":["Switch to the default (new) resolver by removing --use-deprecated=legacy-resolver; it handles path/URL + constraints differently.","Remove the conflicting version constraint for this package from your -c constraints file, or make the constraint point at the same path/URL.","If you must constrain, constrain by the exact same path/URL in both the requirements and the constraints file so link.path matches.","Install the path/URL package without the constraint flag, then add it back once the version is known."],"exampleFix":"# before (legacy resolver + conflicting constraint)\npip install --use-deprecated=legacy-resolver -c constraints.txt ./myfork\ncat constraints.txt  # mypkg==1.2\n\n# after: drop the version pin for the path-installed package\n# constraints.txt: (remove mypkg line)\npip install -c constraints.txt ./myfork","handlingStrategy":"validation","validationCode":"def validate_constraint_compatibility(install_reqs, constraints):\n    # legacy-resolver only: every path/url install must not have a conflicting constraint link\n    cons_by_name = {c.name: c for c in constraints}\n    for ireq in install_reqs:\n        c = cons_by_name.get(ireq.name)\n        if ireq.link and c is not None and c.link is not None:\n            if ireq.link.path != c.link.path:\n                raise SystemExit(\n                    f\"Constraint for {ireq.name} points at a different path than the \"\n                    f\"install requirement; the legacy resolver cannot satisfy this.\"\n                )\n# run before invoking pip with -c","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default to the new resolver; only use --use-deprecated=legacy-resolver when you must.","Keep constraints version-only; do not mix path/URL installs with version constraints for the same project.","If a package is installed from a path/URL, omit it from -c constraints files."],"tags":["pip","resolver","legacy-resolver","constraints","install"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}