Resolving Python packages circular dependency

When I installed the gradio package for Python, it pulled the latest version 4.38.1.

pip3 install gradio

During the installation it tried to install dependent packages, one of them being urllib3 as shown in the output:

Installing collected packages: pydub, ffmpy, websockets, uvloop, uvicorn, urllib3, ujson, toolz, tomlkit, shellingham, semantic-version, ruff, rpds-py, python-multipart, python-dotenv, pyparsing, pygments, pillow, mdurl, markupsafe, kiwisolver, importlib-resources, httptools, fonttools, filelock, dnspython, cycler, contourpy, aiofiles, watchfiles, starlette, referencing, matplotlib, markdown-it-py, jinja2, email_validator, rich, jsonschema-specifications, huggingface-hub, typer, jsonschema, gradio-client, fastapi-cli, altair, fastapi, gradio
  Attempting uninstall: urllib3
    Found existing installation: urllib3 1.26.19
    Uninstalling urllib3-1.26.19:
      Successfully uninstalled urllib3-1.26.19
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
gpt-index 0.8.42 requires urllib3<2, but you have urllib3 2.2.2 which is incompatible.

You'll notice from the output above that it actually uninstalled my existing urllib3 1.26.19 and behind the scenes installed version 2.2.2.

But in the last line of the output, it also recognized that a previously installed package gpt-index 0.8.42 was incompatible with this newly installed version of urllib3.

So what should I do now?

Now I've hit a Python package circular dependency.

  • gpt-index 0.8.42 requires urllib3<2, but I have urllib3 2.2.2 which is incompatible.
  • gradio 4.38.1 requires urllib3~=2.0, but I have urllib3 1.26.19 which is incompatible.

I ended up:

  • Downgrading urllib3 from 2.2.2 to 1.26.19 to support gpt-index 0.8.42
  • Downgrading gradio as a result, from 4.38.1 to 3.50.2 to work with the now lower urllib3 version.

Being new to Python, this package dependency and version compatibility issues are a big mess.