Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pip installation stuck in infinite loop if unresolvable conflicts in dependencies

Pip installation is stuck in an infinite loop if there are unresolvable conflicts in dependencies. To reproduce, pip==20.3.0 and:

pip install pyarrow==2.0.0 azureml-defaults==1.18.0
like image 224
Cody Peterson Avatar asked Dec 02 '20 16:12

Cody Peterson


People also ask

How do you resolve dependency conflicts in pip?

Unfortunately, pip makes no attempt to resolve dependency conflicts. For example, if you install two packages, package A may require a different version of a dependency than package B requires. Pip can install from either Source Distributions (sdist) or Wheel (. whl) files.

Does pip install dependencies of dependencies?

Pip will not flag dependency conflicts. As a result, it will happily install multiple versions of a dependency into your project, which will likely result in errors. One way to avoid dependency conflicts is to use an alternative Python package manager, like conda, poetry or ActiveState's State Tool.

Why is pip backtracking?

Backtracking reduces the risk that installing a new package will accidentally break an existing installed package, and so reduces the risk that your environment gets messed up. To do this, pip has to do more work, to find out which version of a package is a good candidate to install.

How does pip decide which version to install?

Once pip has a list of compatible distributions, it sorts them by version, chooses the most recent version, and then chooses the "best" distribution for that version. It prefers binary wheels if there are any, and if they are multiple it chooses the one most specific to the install environment.


1 Answers

Workarounds:

Local environment: Downgrade pip to < 20.3

Conda environment created from yaml: This will be seen only if conda-forge is highest priority channel, anaconda channel doesn't have pip 20.3 (as of now). To mitigate the issue please explicitly specify pip<20.3 (!=20.3 or =20.2.4 pin to other version) as a conda dependency in the conda specification file

AzureML experimentation: Follow the case above to make sure pinned pip resulted as a conda dependency in the environment object, either from yml file or programmatically

like image 74
vizhur Avatar answered Oct 12 '22 23:10

vizhur