ERROR: Cannot install X and Y because these package versions have conflicting dependencies
ID: pip/conflicting-dependencies
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 23 | active | — | — | — |
| 23 | active | — | — | — |
Root Cause
Pip's modern dependency resolver (introduced in pip 20.3) correctly detects conflicting version requirements between packages. This error means two or more packages require incompatible versions of a shared dependency. Resolution requires identifying compatible version combinations or using tools like pip-compile to find a valid resolution.
genericWorkarounds
-
78% success Create a clean virtual environment and install with constrained versions
python -m venv .venv && source .venv/bin/activate && pip install package-a==X.Y package-b==Z.W. Start from a clean venv to eliminate stale package interference. Use version constraints to find a compatible combination. Check each package's PyPI page for compatible version ranges.
Sources: https://pip.pypa.io/en/stable/user_guide/#requirements-files
-
82% success Use pip-compile from pip-tools to resolve dependencies
pip install pip-tools. Create a requirements.in file with your top-level dependencies (without version pins). Run 'pip-compile requirements.in' to generate a requirements.txt with a fully resolved, conflict-free set of pinned versions. Install with 'pip install -r requirements.txt'.
-
60% success Use the legacy resolver as a temporary fallback
pip install --use-deprecated=legacy-resolver package-a package-b. The legacy resolver does not check for conflicts as strictly, which may allow installation. Warning: this may install incompatible versions that cause runtime errors.
Sources: https://pip.pypa.io/en/stable/topics/dependency-resolution/
Dead Ends
Common approaches that don't work:
-
Running 'pip install --force-reinstall' on the conflicting packages
85% fail
Force-reinstall re-downloads and reinstalls packages but does NOT bypass the dependency resolver. The same conflict will be detected. If combined with --no-deps, it installs without checking dependencies, which leads to runtime ImportError or version-mismatch crashes.
-
Ignoring the error and proceeding with --no-deps
70% fail
Installing with --no-deps skips dependency checks entirely, allowing installation to succeed. However, this virtually guarantees runtime failures: wrong API versions, missing methods, or subtle data corruption when libraries assume specific dependency versions.