-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ResolutionTooDeep while installing a set of packages, undebuggable #12972
Comments
Someone has already reported this issue. I also really want to know how to solve it. |
As discussed with @notatallshaw at PyPA Discord, this seems to have something to do with already installed packages, where pip's attempt to use already satisfied packages significantly increases the burden at backtracking and in the end caused it to give up. |
Yeah, I'm looking to see if I can reproduce @wfjsw issue but in the mean time I suggest installing into an empty virtual environment, providing all your requirements upfront if you can. |
I can reproduce the original issue. (tl;dr the easiest workaround is to add Steps to ReproduceUsing the environment pip 23.0.1, Windows, Python 3.10
Broken Environments and Best PractisesYour original environment was actually "broken", i.e. if you ran This is an unfortunate consequence of the fact that pip is "just an installer", it doesn't consider your whole environment and all your previous requests, it just installs what you tell it to install. This leads to the behaviour that starting with So, one way to keep things always working is to keep a Workarounds in your current situationNormally the best things to do it upgrade your version of pip, unfortunately it looks like this scenario hits a bug in the latest version of pip: #12768 / #12317. I need to do some more testing, but I strongly suspect once a new version of resolvelib is released (sarugaku/resolvelib#159) and pip upgrades to that new version of resolvelib, this will be fixed in pip. I do not have an ETA for that yet. One workaround you can quickly do in the future is to use Another workaround is to use |
Development note: A solution to the problem of the resolver getting stuck because it is trying to use the users existing packages and those packages are already conflicting might be to prefer already installed packages during backtracking, this should quickly solve that the current packages installed need new non-conflicting versions. I am unsure if the required information is available during resolution, but it's worth looking at after that next resolvelib vendoring. |
I did a bit more testing on this today, following the scenario I outlined in #12972 (comment):
So there is still work to do once resolvelib has been vendored, I will use this as a test case for improvements to resolution. |
Hmm... Very counterintuitively, there is almost nothing I can do to prevent a broken environment, similarly in a way to survive a constant dependency hell with a pile of overstrict or ill-defined list of specification across hundreds of libraries. This is well out of the scope of pip but still a cold reality. 😟 I'm worried about Let me check what uv has to provide. |
You can just project / environment management tools, like pdm, uv, rye, or poetry. Instead of installing a set at a time you "add" to your project, e.g. "uv add requests", they then keep track of your environment and make sure it doesn't get broken. And I know that uv and pdm both have options to override specifications when they are not correct.
You should pin these tools to the exact version you want for those packages then, either by adding the exact version with a project / environment management tool, or pinning the exact version you want with a constraints file with pip. I appreciate this is all a learning curve, and managing a Python environment isn't easy as libraries depend on each other in complex ways. Unfortunately pip is extremely limited in offering anything other than install options here, it was designed in a world when the Python ecosystem wasn't so complex, and it doesn't have the resources to expand into project and environment management. Pip should eventually be able to install the commands as listed, as long as I can keep working on resolution, but it might be several releases before this particular scenario works as change is slow due to pip being depended on by so many users and resources being so limited. |
Description
Users are facing with different levels of backtracking depending on the packages (caused by extensions) they already installed. Sometimes there's resolution, but others got infinite backtrack and, finally,
pip._vendor.resolvelib.resolvers.ResolutionTooDeep: 2000000
Related: #11480
cc @chflame163
Expected behavior
No response
pip version
23.0.1
Python version
3.10.11
OS
Windows
How to Reproduce
I can reproduce backtrack but not
ResolutionTooDeep
as I don't have the same set of installed packages. The log attached below is an instance ofResolutionTooDeep
that may aid reproduction:Output
3b28df3d-2ffd-4509-8e18-5df67bd3753a.tmp.txt
Note:
https://pypi.doubanio.com/simple
is an up-to-date mirror of pypi.https://mirror.sjtu.edu.cn/pytorch-wheels/torch_stable.html
is an outdated PyTorch mirror but it is not involved in actual resolution process.https://pypi.oystermercury.top/ms
contains some wheels not available on pypi but is also not related.Code of Conduct
The text was updated successfully, but these errors were encountered: