pip `ResolutionError` when installing requirements from file to duplicate a virtualenv

Viewed 19

I'm trying to create a duplicate of a python virtualenv on my local machine. I ran pip freeze > requirements.txt within my existing virtualenv, then deactivated it before creating and activating a brand new virtualenv with the exact same python version (3.8.10). I then ran pip install -r requirements.txt to add all the packages I need but it fails with this error:

ERROR: Cannot install -r requirements.txt (line 31), -r requirements.txt (line 40), -r requirements.txt (line 48) and Jinja2==2.11.3 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested Jinja2==2.11.3
    cookiecutter 2.1.1 depends on Jinja2<4.0.0 and >=2.7
    distributed 2022.8.0 depends on jinja2
    flask 2.2.2 depends on Jinja2>=3.0

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

I'm struggling to understand how this can be as all of these packages are installed together in my original virtualenv, so the requirements must be resolved there. Also, I tried removing that Jinja2 package from the requirements.txt file just in case there was something weird about that but then it just complains about other packages.

Can anyone explain to me why I see this behaviour and what I could try to resolve it?

0 Answers
Related