diff --git a/news/11314.bugfix.rst b/news/11314.bugfix.rst new file mode 100644 index 00000000000..02d78dc47ff --- /dev/null +++ b/news/11314.bugfix.rst @@ -0,0 +1 @@ +Avoid ``AttributeError`` when removing the setuptools-provided ``_distutils_hack`` and it is missing its implementation. diff --git a/src/pip/_internal/locations/_distutils.py b/src/pip/_internal/locations/_distutils.py index 1b8b42606d7..fbcb04f488f 100644 --- a/src/pip/_internal/locations/_distutils.py +++ b/src/pip/_internal/locations/_distutils.py @@ -11,7 +11,7 @@ # rationale for why this is done within pip. try: __import__("_distutils_hack").remove_shim() -except ImportError: +except (ImportError, AttributeError): pass import logging