Pipenv "Locking Failed!" - Fix Pipfile.lock Resolution in CI
Pipenv could not resolve a consistent set of versions from your Pipfile, so locking failed. It is the Pipenv analogue of a pip resolution conflict - two constraints, or a Python requirement, cannot all be satisfied.
What this error means
pipenv lock or pipenv install aborts with Locking Failed! and "Your dependencies could not be resolved", sometimes naming the conflicting packages. It reproduces from the same Pipfile until a constraint is changed.
Locking Failed!
ERROR:pipenv.patched.pip._internal.resolution... ResolutionImpossible:
Your dependencies could not be resolved. You likely have a mismatch in
your sub-dependencies.Common causes
Conflicting version constraints in the Pipfile
Two requirements pin incompatible versions of a shared package, so no lock satisfies both.
Python version mismatch
The [requires] python_version in the Pipfile, or the interpreter Pipenv selected, does not overlap a dependency’s supported Python.
Stale lock against an edited Pipfile
The Pipfile changed without re-locking, so CI with --deploy rejects the mismatch.
How to fix it
Re-lock and read the conflict
Lock verbosely to see which constraints collide, then relax the over-tight one.
pipenv lock --verbose
# after fixing constraints
pipenv install --deploy # fail if Pipfile.lock is out of dateAlign the Python version
[requires]
python_version = "3.11"How to prevent it
- Commit
Pipfile.lockand re-lock after editing thePipfile. - Use
pipenv install --deployin CI to catch lock drift. - Keep
python_versionaligned with your dependencies’ support.