This error occurs when you have conflicting version requirements: one package needs version X.0 of a dependency, but another needs Y.0. Virtual environments and requirements files help resolve this.
Fixes pkg_resources.VersionConflict: (setuptools X) but (setuptools>=Y) is required
pip listpip listpkg_resources.VersionConflict: (setuptools X) but (setuptools>=Y) is required
On this page
The "requires a different version" error means two or more packages you're trying to use have incompatible dependency requirements. For example: - Package A requires: requests>=2.28.0 - Package B requires: requests<2.25.0 - You can't satisfy both requirements simultaneously This happens because: 1. Packages in your project depend on different versions of the same library 2. You're using very old or very new versions of packages together 3. Package maintainers haven't updated version constraints for compatibility Solutions include updating packages, relaxing version constraints, or using different packages that are compatible.
See what versions are installed and required:
pip listFor detailed dependency information:
pip install pipdeptree
pipdeptreeModern pip has a better dependency resolver:
pip install --upgrade pip
pip install --use-new-resolver package-nameSpecify compatible version ranges:
pip install 'package-a>=1.0,<2.0' 'package-b>=2.1,<3.0'Or let pip resolve automatically:
pip install package-a package-bCreate a requirements.txt with exact versions that work together:
package-a==1.5.2
package-b==2.3.0
package-c==0.1.0Install from it:
pip install -r requirements.txtCreate a clean environment and install from scratch:
python3 -m venv fresh_env
source fresh_env/bin/activate
pip install package-a package-bUse pip freeze > requirements.txt to capture a working environment. For reproducible builds, use poetry or pipenv which handle dependency resolution better than pip with requirements.txt.