Open wfjsw opened 1 month ago
Someone has already reported this issue. I also really want to know how to solve it. This issue seems to only occur when installing dependencies on the Aki ComfyUI Launcher. I tried manually installing requirements.txt with ComfyUI official portable or conda environment and did not encounter this issue.
Someone has already reported this issue. I also really want to know how to solve it. This issue seems to only occur when installing dependencies on the Aki ComfyUI Launcher. I tried manually installing requirements.txt with ComfyUI official portable or conda environment and did not encounter this issue.
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 --upgrade
on to your pip install
)
Using the environment pip 23.0.1, Windows, Python 3.10
pip install -r env.txt --no-deps
pip install -r requirements.txt
Your original environment was actually "broken", i.e. if you ran pip check
you would see you had packages installed that conflict with each other, that is, at least one package version installed which a different package says that version shouldn't be installed.
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 pip install {package1}
followed by pip install {package2}
can lead to a broken environment where as starting with pip install {package1} {package2}
will never lead to a broken environment.
So, one way to keep things always working is to keep a requirements.txt
with all your requirements you need, add to it every time you need something new, and always run pip install -r requirements.txt
and because it has everything you need the chances of it breaking the environment is very low. If you do run into a problem you can always create a new virtual environment and install from that file, and because it has everything you need you're set.
Normally 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: https://github.com/pypa/pip/issues/12768 / https://github.com/pypa/pip/issues/12317. I need to do some more testing, but I strongly suspect once a new version of resolvelib is released (https://github.com/sarugaku/resolvelib/issues/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 --upgrade
, i.e. at step 4. do pip install -r requirements.txt --upgrade
, this tells pip not to prefer the already installed versions of packages, and to get the latest versions based on your requirements, in the above example this causes pip to be able to install the packages fine. In general, this is probably a good options when your environment is broken.
Another workaround is to use uv
, a competitor to pip that has a "pip like" interface, i.e. you run uv pip install
instead of pip install
. They are focused on being hyper fast and can probably do any kind of resolution you need, they are not 100% compatible with pip, but for any modern package it should work. Installation guide: https://docs.astral.sh/uv/getting-started/installation/. You will probably need to read the pip compatability guide particularly the section "Packages that exist on multiple indexes": https://docs.astral.sh/uv/pip/compatibility
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 https://github.com/pypa/pip/issues/12972#issuecomment-2364096564:
ResolutionTooDeep
ResolutionImpossible
(incorrect)ResolutionTooDeep
🙁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 --upgrade
changing too many out of scope packages. There is a certain list of things I never want it to touch on automatically, for example torch (it will always install the wrong version) and onnxruntime (the installation order matters💩). I'm in halfways researching for a pinning method that would not fail the resolution process (more literally broken environment but actually works). Similar issue for uv.
Let me check what uv has to provide.
Very counterintuitively, there is almost nothing I can do to prevent a broken environment
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.
I'm worried about --upgrade changing too many out of scope packages. There is a certain list of things I never want it to touch on automatically, for example torch (it will always install the wrong version) and onnxruntime (the installation order matters💩).
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