Install the latest pip with the following command:
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
The problem is that the solution that actually worked for me is not the accepted one, so I am providing the second answer as the solution to my problem.
Using:
conda install -c anaconda html5lib
It's always best to run pip as a main module with the version of Python you want to install for:
python3.9 -m pip install ...
python3.10 -m pip install ...
python3.11 -m pip install ...
If you want to force an upgrade, use the --upgrade option.
To resolve the ImportError: cannot import name 'html5lib' from 'pip._vendor' (/usr/lib/python3/dist-packages/pip/_vendor/__init__.py) error, you can follow these steps:
pip install html5lib
pip install --upgrade html5lib
pip install --upgrade --force-reinstall pip
git clone https://github.com/html5lib/html5lib-python.git
cd html5lib-python
python setup.py install