Decoding the 'No module named pip._vendor.six' error message
Occasionally when manipulating complex Python setups users may encounter the error message:
ModuleNotFoundError: No module named 'pip._vendor.six'
The reason for this message as follows:
- The
pippackage uses thesixpackage (and a number of other, third party packages) - These packages can be bundled with pip, in which case it is
copied into the
pip._vendoredmodule - Or the package could be supplied through another mechanism, such as
the system-wide package management (e.g.,
apt, `dnf’, etc). - The choice between (2) or (3) is made within the source code of
pipitself: if the DEBUNDLED variable is set, pip will try to install the system-wide packages and thepip._vendoredmodule will be empty
The error message above is seen if pip is DEBUNDLED (i.e., 3 is true) and if the required six package is not in fact available trough that other mechanism.
How to fix?
Simplest option is to install a BUNDLED version of pip. Obviously
this can’t be done with pip itself as the missing six library
breaks it, so is best done by downloading the zipped version. Easy way
to do this is:
curl -sS https://bootstrap.pypa.io/get-pip.py | python
Other option is to install the required packages through an
alternative mechanism (e.g., apt install python-six) and ensure that
this installation is visible to the version of Python that you are
using (e.g. by adjusting `PYTHON_PATH’ if needed.)